devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=95a88f5a6c5c8bcc8bacb014742e37e3bfaf503d

commit 95a88f5a6c5c8bcc8bacb014742e37e3bfaf503d
Author: Christopher Michael <devilho...@comcast.net>
Date:   Thu Feb 25 10:02:07 2021 -0500

    eeze_disk: fix potential memory leak
    
    If allocation for disk fails, then we leak memory from previously
    called _new_device function.
    
    This patch based on D12223 from akanad (Wonki Kim)
    
    ref D12223
---
 src/lib/eeze/eeze_disk.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/lib/eeze/eeze_disk.c b/src/lib/eeze/eeze_disk.c
index ea413976fc..9747b9801a 100644
--- a/src/lib/eeze/eeze_disk.c
+++ b/src/lib/eeze/eeze_disk.c
@@ -175,7 +175,11 @@ eeze_disk_new(const char *path)
      return NULL;
 
    if (!(disk = calloc(1, sizeof(Eeze_Disk))))
-     return NULL;
+     {
+        eina_stringshare_del(syspath);
+        udev_device_unref(dev);
+        return NULL;
+     }
 
    if (is_dev)
      {
@@ -185,7 +189,6 @@ eeze_disk_new(const char *path)
    else
      disk->syspath = eina_stringshare_add(udev_device_get_syspath(dev));
 
-
    disk->device = dev;
    disk->mount_opts = EEZE_DISK_MOUNTOPT_DEFAULTS;
    disk->mount_cmd_changed = EINA_TRUE;

-- 


Reply via email to