* 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.
This commit is contained in:
Ian Lance Taylor 1994-09-14 20:21:21 +00:00
parent 9be909aef7
commit e4798f4093
2 changed files with 15 additions and 5 deletions

View file

@ -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.

View file

@ -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 = "???";