summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Conerly <tomconerly@gmail.com>2015-07-27 11:35:29 -0700
committerAliaksey Kandratsenka <alk@tut.by>2015-08-01 12:34:08 -0700
commite1d1311cfb6312cd44e086c879f3e95cbfa0eb9d (patch)
treedc74b1b2ecdd97a419c9acd4a7cd6355a47f7c55
parentb5b79860fd2b8e1a9b0573e93f942695f2992b59 (diff)
downloadgperftools-e1d1311cfb6312cd44e086c879f3e95cbfa0eb9d.tar.gz
issue-699: Free list on error paths
-rw-r--r--src/heap-profile-table.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/heap-profile-table.cc b/src/heap-profile-table.cc
index 5191afb..7486468 100644
--- a/src/heap-profile-table.cc
+++ b/src/heap-profile-table.cc
@@ -350,7 +350,10 @@ int HeapProfileTable::FillOrderedProfile(char buf[], int size) const {
// is remaining, and then move the maps info one last time to close
// any gaps. Whew!
int map_length = snprintf(buf, size, "%s", kProcSelfMapsHeader);
- if (map_length < 0 || map_length >= size) return 0;
+ if (map_length < 0 || map_length >= size) {
+ dealloc_(list);
+ return 0;
+ }
bool dummy; // "wrote_all" -- did /proc/self/maps fit in its entirety?
map_length += FillProcSelfMaps(buf + map_length, size - map_length, &dummy);
RAW_DCHECK(map_length <= size, "");
@@ -361,7 +364,10 @@ int HeapProfileTable::FillOrderedProfile(char buf[], int size) const {
Stats stats;
memset(&stats, 0, sizeof(stats));
int bucket_length = snprintf(buf, size, "%s", kProfileHeader);
- if (bucket_length < 0 || bucket_length >= size) return 0;
+ if (bucket_length < 0 || bucket_length >= size) {
+ dealloc_(list);
+ return 0;
+ }
bucket_length = UnparseBucket(total_, buf, bucket_length, size,
" heapprofile", &stats);