From: Ian Lance Taylor Date: Wed, 14 Sep 1994 20:21:21 +0000 (+0000) Subject: * objdump.c (disassemble_data): Initialize prevline to 0. Make X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e4798f4093a02cb1626e808df98bf248b83b0483;p=binutils-gdb.git * objdump.c (disassemble_data): Initialize prevline to 0. Make prev_function non const. Copy functionname into an malloc buffer when setting prev_function, instead of assuming that the string will last forever. --- diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 727c1d895a7..35cca2c5acb 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,5 +1,10 @@ Wed Sep 14 12:19:07 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + * objdump.c (disassemble_data): Initialize prevline to 0. Make + prev_function non const. Copy functionname into an malloc buffer + when setting prev_function, instead of assuming that the string + will last forever. + * nm.c: Include libiberty.h. (sort_by_size): New static variable. (long_options): Add --size-sort. diff --git a/binutils/objdump.c b/binutils/objdump.c index 7f0c9f9a8e8..b158c53d101 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -451,8 +451,8 @@ disassemble_data (abfd) struct disassemble_info disasm_info; struct objdump_disasm_info aux; - int prevline; - CONST char *prev_function = ""; + int prevline = 0; + char *prev_function = NULL; asection *section; @@ -561,11 +561,16 @@ disassemble_data (abfd) &functionname, &line)) { - if (functionname && *functionname - && strcmp(functionname, prev_function)) + if (functionname + && *functionname != '\0' + && (prev_function == NULL + || strcmp (functionname, prev_function) != 0)) { printf ("%s():\n", functionname); - prev_function = functionname; + if (prev_function != NULL) + free (prev_function); + prev_function = xmalloc (strlen (functionname) + 1); + strcpy (prev_function, functionname); } if (!filename) filename = "???";