bluetooth: Fix Memory Leak 35/60035/2
authorNiraj Kumar Goit <niraj.g@samsung.com>
Mon, 22 Feb 2016 14:20:53 +0000 (19:50 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Tue, 23 Feb 2016 07:25:51 +0000 (12:55 +0530)
To avoid memory leak issue allocate memory to tethering structure
after all error checks.

Change-Id: If10578acce2eb8eedbdbc96f73a30c79c1a7a125
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
plugins/bluetooth.c

index e1d4b59..24f3aa5 100755 (executable)
@@ -723,7 +723,7 @@ static bool tethering_create(const char *path,
                struct connman_technology *technology, const char *bridge,
                bool enabled)
 {
-       struct tethering_info *tethering = g_new0(struct tethering_info, 1);
+       struct tethering_info *tethering;
        GDBusProxy *proxy;
        const char *method;
        bool result;
@@ -737,6 +737,8 @@ static bool tethering_create(const char *path,
        if (!proxy)
                return false;
 
+       tethering = g_new0(struct tethering_info, 1);
+
        tethering->technology = technology;
        tethering->bridge = g_strdup(bridge);
        tethering->enable = enabled;