From: Florian Krohm Date: Wed, 16 Jan 2013 03:18:19 +0000 (+0000) Subject: Fix two memory leaks. Spotted by Coverity. X-Git-Tag: svn/VALGRIND_3_9_0~447 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d62fe23131a91d26f0f9dc853879fb57237ef2a9;p=thirdparty%2Fvalgrind.git Fix two memory leaks. Spotted by Coverity. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13234 --- diff --git a/cachegrind/cg_merge.c b/cachegrind/cg_merge.c index 20556fc31b..97e5863268 100644 --- a/cachegrind/cg_merge.c +++ b/cachegrind/cg_merge.c @@ -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++)