File libcdio-0.94-leak-17.patch of Package libcdio.7811

From 56a5ec730504c4ce358feb6fb5edc104910a6fca Mon Sep 17 00:00:00 2001
From: "R. Bernstein" <rocky@gnu.org>
Date: Sat, 9 Dec 2017 20:26:12 -0500
Subject: [PATCH 17/20] More memory leak and invalid access removal

---
 src/cd-drive.c | 19 +++++++++++--------
 src/iso-info.c |  1 -
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/cd-drive.c b/src/cd-drive.c
index 7deb3e0e..50b7b15d 100644
--- a/src/cd-drive.c
+++ b/src/cd-drive.c
@@ -122,14 +122,13 @@ parse_options (int argc, char *argv[])
 
     case '?':
       fprintf(stdout, helpText, program_name);
-      free(program_name);
+      goto error_exit;
       exit(EXIT_INFO);
       break;
 
     case OP_USAGE:
       fprintf(stderr, usageText, program_name);
-      free(program_name);
-      exit(EXIT_FAILURE);
+      goto error_exit;
       break;
 
     case OP_HANDLED:
@@ -148,8 +147,7 @@ parse_options (int argc, char *argv[])
     if (source_name != NULL) {
       report( stderr, "%s: Source specified in option %s and as %s\n",
 	      program_name, source_name, remaining_arg);
-      free(program_name);
-      exit (EXIT_FAILURE);
+      goto error_exit;
     }
 
     if (opts.source_image == (source_image_t) DRIVER_DEVICE)
@@ -160,12 +158,17 @@ parse_options (int argc, char *argv[])
     if (optind < argc) {
       report( stderr, "%s: Source specified in previously %s and %s\n",
 	      program_name, source_name, remaining_arg);
-      free(program_name);
-      exit (EXIT_FAILURE);
+      goto error_exit;
     }
   }
-
   return true;
+ error_exit:
+  if (source_name != NULL) {
+    free(source_name);
+  }
+  free(program_name);
+  exit (EXIT_FAILURE);
+
 }
 
 /* CDIO logging routines */
diff --git a/src/iso-info.c b/src/iso-info.c
index 1eba0d9e..2898ca36 100644
--- a/src/iso-info.c
+++ b/src/iso-info.c
@@ -475,7 +475,6 @@ main(int argc, char *argv[])
   p_iso = iso9660_open_ext (source_name, iso_extension_mask);
 
   if (p_iso==NULL) {
-    free(source_name);
     err_exit("Error in opening ISO-9660 image%s\n", "");
   }
 
-- 
2.17.0
openSUSE Build Service is sponsored by