summaryrefslogtreecommitdiff
path: root/gas/stabs.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@delorie.com>2001-03-15 19:30:32 +0000
committerDJ Delorie <dj@delorie.com>2001-03-15 19:30:32 +0000
commitcee94e5ff671ba5ef767825bca6b2738bdd0b872 (patch)
tree4dba13d5912f2330832b22f156d0582a37789ee6 /gas/stabs.c
parentc1b33521c42786858eddcb3647309c7d37619068 (diff)
downloadbinutils-redhat-cee94e5ff671ba5ef767825bca6b2738bdd0b872.tar.gz
* stabs.c (s_stab_generic): Don't corrupt the notes obstack by
blindly freeing string if it isn't at the top of the obstack.
Diffstat (limited to 'gas/stabs.c')
-rw-r--r--gas/stabs.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/gas/stabs.c b/gas/stabs.c
index e402f70648..eed11b31c6 100644
--- a/gas/stabs.c
+++ b/gas/stabs.c
@@ -185,7 +185,7 @@ s_stab_generic (what, stab_secname, stabstr_secname)
char *stabstr_secname;
{
long longint;
- char *string;
+ char *string, *saved_string_obstack_end;
int type;
int other;
int desc;
@@ -199,12 +199,19 @@ s_stab_generic (what, stab_secname, stabstr_secname)
'd' indicating which type of .stab this is. */
if (what != 's')
- string = "";
+ {
+ string = "";
+ saved_string_obstack_end = 0;
+ }
else
{
int length;
string = demand_copy_C_string (&length);
+ /* FIXME: We should probably find some other temporary storage
+ for string, rather than leaking memory if someone else
+ happens to use the notes obstack. */
+ saved_string_obstack_end = notes.next_free;
SKIP_WHITESPACE ();
if (*input_line_pointer == ',')
input_line_pointer++;
@@ -335,8 +342,9 @@ s_stab_generic (what, stab_secname, stabstr_secname)
stroff = get_stab_string_offset (string, stabstr_secname);
if (what == 's')
{
- /* release the string */
- obstack_free (&notes, string);
+ /* Release the string, if nobody else has used the obstack. */
+ if (saved_string_obstack_end == notes.next_free)
+ obstack_free (&notes, string);
}
/* At least for now, stabs in a special stab section are always