]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix two memory leaks. Spotted by Coverity.
authorFlorian Krohm <florian@eich-krohm.de>
Wed, 16 Jan 2013 03:18:19 +0000 (03:18 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Wed, 16 Jan 2013 03:18:19 +0000 (03:18 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13234

cachegrind/cg_merge.c

index 20556fc31b4b3caa016fb5fd3ed5935871ebd6f7..97e5863268241c881a3649136623143339cf35ae 100644 (file)
@@ -277,8 +277,10 @@ static Counts* new_Counts ( Int n_counts, /*COPIED*/ULong* counts )
 
    assert(n_counts >= 0);
    cts->counts = malloc(n_counts * sizeof(ULong));
-   if (cts->counts == NULL)
+   if (cts->counts == NULL) {
+      free(cts);
       return NULL;
+   }
 
    cts->n_counts = n_counts;
    for (i = 0; i < n_counts; i++)
@@ -296,8 +298,10 @@ static Counts* new_Counts_Zeroed ( Int n_counts )
 
    assert(n_counts >= 0);
    cts->counts = malloc(n_counts * sizeof(ULong));
-   if (cts->counts == NULL)
+   if (cts->counts == NULL) {
+      free(cts);
       return NULL;
+   }
 
    cts->n_counts = n_counts;
    for (i = 0; i < n_counts; i++)