1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Don't free allocated uncompressed_debug_line until backtrace is printed

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2018-08-13 08:48:30 +00:00
parent 0efd00bf4f
commit 0ca505347c

View file

@ -127,6 +127,7 @@ struct obj_info {
const char *path; /* object path */ const char *path; /* object path */
void *mapped; void *mapped;
size_t mapped_size; size_t mapped_size;
void *uncompressed_debug_line;
uintptr_t base_addr; uintptr_t base_addr;
obj_info_t *next; obj_info_t *next;
}; };
@ -503,20 +504,18 @@ parse_compressed_debug_line(int num_traces, void **traces,
if (!uncompressed_debug_line) return -1; if (!uncompressed_debug_line) return -1;
ret = uncompress(uncompressed_debug_line, &destsize, ret = uncompress(uncompressed_debug_line, &destsize,
(const Bytef *)debug_line + sizeof(ElfW(Chdr)), size-sizeof(ElfW(Chdr))); (const Bytef *)debug_line + sizeof(ElfW(Chdr)), size-sizeof(ElfW(Chdr)));
if (ret != Z_OK) { /* Z_OK = 0 */ if (ret != Z_OK) goto fail;
goto finish;
}
ret = parse_debug_line(num_traces, traces, ret = parse_debug_line(num_traces, traces,
uncompressed_debug_line, uncompressed_debug_line,
destsize, destsize,
obj, lines, offset); obj, lines, offset);
if (ret) { if (ret) goto fail;
goto finish; obj->uncompressed_debug_line = uncompressed_debug_line;
} return 0;
finish: fail:
free(uncompressed_debug_line); free(uncompressed_debug_line);
return ret ? -1 : 0; return -1;
} }
#endif #endif
@ -843,6 +842,9 @@ next_line:
if (o->mapped_size) { if (o->mapped_size) {
munmap(o->mapped, o->mapped_size); munmap(o->mapped, o->mapped_size);
} }
if (o->uncompressed_debug_line) {
free(o->uncompressed_debug_line);
}
free(o); free(o);
} }
free(lines); free(lines);