[PATCH] irmc: Fix possible memory leak in handling of location

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 plugins/irmc.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/plugins/irmc.c b/plugins/irmc.c
index 2a8c543..0a0dc93 100644
--- a/plugins/irmc.c
+++ b/plugins/irmc.c
@@ -401,6 +401,7 @@ static void *irmc_open(const char *name, int oflag, mode_t mode, void *context,
 {
 	struct irmc_session *irmc = context;
 	int ret = 0;
+	void *retp = NULL
 	char *path;
 
 	DBG("name %s context %p", name, context);
@@ -422,22 +423,26 @@ static void *irmc_open(const char *name, int oflag, mode_t mode, void *context,
 		path = g_build_filename("/", name, NULL);
 
 	if (g_str_equal(path, PB_DEVINFO))
-		return irmc_open_devinfo(irmc, err);
+		retp = irmc_open_devinfo(irmc, err);
 	else if (g_str_equal(path, PB_CONTACTS))
-		return irmc_open_pb(irmc, err);
+		retp = irmc_open_pb(irmc, err);
 	else if (g_str_equal(path, PB_INFO_LOG))
-		return irmc_open_info(irmc, err);
+		retp = irmc_open_info(irmc, err);
 	else if (g_str_equal(path, PB_CC_LOG))
-		return irmc_open_cc(irmc, err);
+		retp = irmc_open_cc(irmc, err);
 	else if (g_str_has_prefix(path, PB_CALENDAR_FOLDER))
-		return irmc_open_cal(irmc, err);
+		retp = irmc_open_cal(irmc, err);
 	else if (g_str_has_prefix(path, PB_NOTES_FOLDER))
-		return irmc_open_nt(irmc, err);
+		retp = irmc_open_nt(irmc, err);
 	else if (g_str_has_prefix(path, PB_LUID_FOLDER))
-		return irmc_open_luid(irmc, err);
+		retp = irmc_open_luid(irmc, err);
 	else
 		ret = -EBADR;
 
+	g_free(path);
+	if (retp)
+		return retp;
+
 fail:
 	if (err)
 		*err = ret;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux