eeze_net: fix a potentional memory leak case 00/258700/1
authorWonki Kim <wonki_.kim@samsung.com>
Thu, 24 Dec 2020 02:43:28 +0000 (11:43 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Mon, 24 May 2021 10:37:31 +0000 (19:37 +0900)
Summary:
if `net` equals zero and `device` has allocated properly at the same time, memory leaks.
this patch fixes it.

Reviewers: Hermet, bu5hm4n, zmike

Reviewed By: Hermet

Subscribers: vtorri, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D12221

Change-Id: Ie70eb0da84b29c23d3192f03bb09d6a6593381e4

src/lib/eeze/eeze_net.c

index 47887d7..bdd7181 100644 (file)
@@ -78,7 +78,11 @@ eeze_net_new(const char *name)
      }
    if (!device) return NULL;
    net = calloc(1, sizeof(Eeze_Net));
-   if (!net) return NULL;
+   if (!net)
+     {
+        udev_device_unref(device);
+        return NULL;
+     }
    EINA_REFCOUNT_INIT(net);
    net->device = device;
    net->syspath = syspath;