diff options
author | Christopher Michael <devilhorns@comcast.net> | 2021-02-25 10:02:07 -0500 |
---|---|---|
committer | Christopher Michael <devilhorns@comcast.net> | 2021-02-25 10:05:26 -0500 |
commit | 95a88f5a6c5c8bcc8bacb014742e37e3bfaf503d (patch) | |
tree | 51332aaa74b9179db792a2aaed618cef092f9360 /src/lib | |
parent | 691621336ad68b29481b8438b89bcca6e148b7f2 (diff) |
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
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/eeze/eeze_disk.c | 7 |
1 files 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) | |||
175 | return NULL; | 175 | return NULL; |
176 | 176 | ||
177 | if (!(disk = calloc(1, sizeof(Eeze_Disk)))) | 177 | if (!(disk = calloc(1, sizeof(Eeze_Disk)))) |
178 | return NULL; | 178 | { |
179 | eina_stringshare_del(syspath); | ||
180 | udev_device_unref(dev); | ||
181 | return NULL; | ||
182 | } | ||
179 | 183 | ||
180 | if (is_dev) | 184 | if (is_dev) |
181 | { | 185 | { |
@@ -185,7 +189,6 @@ eeze_disk_new(const char *path) | |||
185 | else | 189 | else |
186 | disk->syspath = eina_stringshare_add(udev_device_get_syspath(dev)); | 190 | disk->syspath = eina_stringshare_add(udev_device_get_syspath(dev)); |
187 | 191 | ||
188 | |||
189 | disk->device = dev; | 192 | disk->device = dev; |
190 | disk->mount_opts = EEZE_DISK_MOUNTOPT_DEFAULTS; | 193 | disk->mount_opts = EEZE_DISK_MOUNTOPT_DEFAULTS; |
191 | disk->mount_cmd_changed = EINA_TRUE; | 194 | disk->mount_cmd_changed = EINA_TRUE; |