diff options
author | Than McIntosh <thanm@google.com> | 2017-05-19 16:07:24 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-05-19 16:07:24 +0000 |
commit | 281161d16bb6c0a3759c86270c885c98c9eb49eb (patch) | |
tree | 2077ab38904da7c5abb663193b3992c093264c51 /libbacktrace/dwarf.c | |
parent | 51cd6b78eedaefec65059f7a8cbca1f2b9bf4878 (diff) |
dwarf.c (free_line_header): Don't free dirs if dirs_count == 0.
* dwarf.c (free_line_header): Don't free dirs if dirs_count == 0.
(read_line_header): Don't allocate dirs if dirs_count == 0.
* edtest.c: New file.
* edtest2.c: New file.
* Makefile.am (edtest_SOURCES, edtest_LDADD): Define.
(check_PROGRAMS): Add edtest.
(edtest2_build.c, gen_edtest2_build): New targets.
* Makefile.in: Rebuild.
From-SVN: r248295
Diffstat (limited to 'libbacktrace/dwarf.c')
-rw-r--r-- | libbacktrace/dwarf.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/libbacktrace/dwarf.c b/libbacktrace/dwarf.c index 80c64034092..9a89735fdf0 100644 --- a/libbacktrace/dwarf.c +++ b/libbacktrace/dwarf.c @@ -1563,16 +1563,15 @@ add_line (struct backtrace_state *state, struct dwarf_data *ddata, return 1; } -/* Free the line header information. If FREE_FILENAMES is true we - free the file names themselves, otherwise we leave them, as there - may be line structures pointing to them. */ +/* Free the line header information. */ static void free_line_header (struct backtrace_state *state, struct line_header *hdr, backtrace_error_callback error_callback, void *data) { - backtrace_free (state, hdr->dirs, hdr->dirs_count * sizeof (const char *), - error_callback, data); + if (hdr->dirs_count != 0) + backtrace_free (state, hdr->dirs, hdr->dirs_count * sizeof (const char *), + error_callback, data); backtrace_free (state, hdr->filenames, hdr->filenames_count * sizeof (char *), error_callback, data); @@ -1633,12 +1632,16 @@ read_line_header (struct backtrace_state *state, struct unit *u, ++hdr->dirs_count; } - hdr->dirs = ((const char **) - backtrace_alloc (state, - hdr->dirs_count * sizeof (const char *), - line_buf->error_callback, line_buf->data)); - if (hdr->dirs == NULL) - return 0; + hdr->dirs = NULL; + if (hdr->dirs_count != 0) + { + hdr->dirs = ((const char **) + backtrace_alloc (state, + hdr->dirs_count * sizeof (const char *), + line_buf->error_callback, line_buf->data)); + if (hdr->dirs == NULL) + return 0; + } i = 0; while (*hdr_buf.buf != '\0') |