]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix a memory leak found by IBM's BEAM checker.
authorFlorian Krohm <florian@eich-krohm.de>
Fri, 12 Sep 2014 20:53:43 +0000 (20:53 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Fri, 12 Sep 2014 20:53:43 +0000 (20:53 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14527

memcheck/mc_errors.c

index c5f18fe8cd82f54c742fa2a222a8d55f568b3408..e6a2133b28ee9d8e2f711efbe1003eaac723da2e 100644 (file)
@@ -1351,22 +1351,29 @@ Bool MC_(read_extra_suppression_info) ( Int fd, HChar** bufpp,
       }
    } else if (VG_(get_supp_kind)(su) == FishyValueSupp) {
       MC_FishyValueExtra *extra;
-      HChar *p;
+      HChar *p, *function_name, *argument_name = NULL;
 
       eof = VG_(get_line) ( fd, bufpp, nBufp, lineno );
       if (eof) return True;
 
-      extra = VG_(malloc)("mc.resi.3", sizeof *extra);
-      extra->function_name = VG_(strdup)("mv.resi.4", *bufpp);
-
       // The suppression string is: function_name(argument_name)
-      p = VG_(strchr)(extra->function_name, '(');
-      if (p == NULL) return False;  // malformed suppression string
-      *p++ = '\0';
-      extra->argument_name = p;
-      p = VG_(strchr)(p, ')');
-      if (p == NULL) return False;  // malformed suppression string
-      *p = '\0';
+      function_name = VG_(strdup)("mv.resi.4", *bufpp);
+      p = VG_(strchr)(function_name, '(');
+      if (p != NULL) {
+         *p++ = '\0';
+         argument_name = p;
+         p = VG_(strchr)(p, ')');
+         if (p != NULL)
+            *p = '\0';
+      }
+      if (p == NULL) {    // malformed suppression string
+         VG_(free)(function_name);
+         return False;
+      }
+
+      extra = VG_(malloc)("mc.resi.3", sizeof *extra);
+      extra->function_name = function_name;
+      extra->argument_name = argument_name;
 
       VG_(set_supp_extra)(su, extra);
    }