issue-699: Free list on error paths
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 @@
// 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 @@
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);