Fix two memory leaks. Spotted by Coverity.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13234 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/cachegrind/cg_merge.c b/cachegrind/cg_merge.c
index 20556fc..97e5863 100644
--- a/cachegrind/cg_merge.c
+++ b/cachegrind/cg_merge.c
@@ -277,8 +277,10 @@
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 @@
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++)