File libcdio-0.94-leak-16.patch of Package libcdio.24379
Partial patch.
From 213bc176b9be84ac61d52fb86cee33e8f14b80d7 Mon Sep 17 00:00:00 2001
From: "R. Bernstein" <rocky@gnu.org>
Date: Fri, 8 Dec 2017 21:21:21 -0500
Subject: [PATCH 16/20] DRY code. More leak removal.
---
lib/driver/FreeBSD/freebsd.c | 13 +++++--------
lib/driver/gnu_linux.c | 19 ++++++++++---------
lib/driver/netbsd.c | 13 +++++++++----
3 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/lib/driver/gnu_linux.c b/lib/driver/gnu_linux.c
index fc339e1a..e7967397 100644
--- a/lib/driver/gnu_linux.c
+++ b/lib/driver/gnu_linux.c
@@ -1775,8 +1775,7 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode)
if (NULL == psz_orig_source) {
psz_source=cdio_get_default_device_linux();
if (NULL == psz_source) {
- free(_data);
- return NULL;
+ goto err_exit;
}
set_arg_linux(_data, "source", psz_source);
@@ -1789,13 +1788,14 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode)
#if 0
cdio_info ("source %s is not a device", psz_orig_source);
#endif
- free(_data);
- return NULL;
+ goto err_exit;
}
}
ret = cdio_new ((void *)_data, &_funcs);
- if (ret == NULL) return NULL;
+ if (ret == NULL) {
+ goto err_exit;
+ }
ret->driver_id = DRIVER_LINUX;
@@ -1809,11 +1809,12 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode)
if (cdio_generic_init(_data, open_access_mode)) {
set_scsi_tuple_linux(_data);
return ret;
- } else {
- cdio_generic_free (_data);
- free(ret);
- return NULL;
}
+ free(ret);
+
+ err_exit:
+ cdio_generic_free(_data);
+ return NULL;
#else
return NULL;
--
2.17.0