Skip to content

Commit 9e99d10

Browse files
committed
PR30828, notes obstack memory corruption
Commit 3bab069 carelessly allowed "string" to be released from the notes obstack twice, with the second call to obstack_free releasing memory for a fixup that just happened to be the same size as the original string. The fixup then of course was overwritten. This patch fixes that problem, and another that could occur on an error path. PR 30828 * stabs.c (s_stab_generic): Don't free string twice. Don't blow away entire notes obstack on a missing string.
1 parent 313b284 commit 9e99d10

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

gas/stabs.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ s_stab_generic (int what,
262262
{
263263
as_warn (_(".stab%c: missing string"), what);
264264
ignore_rest_of_line ();
265-
goto out;
265+
goto out2;
266266
}
267267
/* FIXME: We should probably find some other temporary storage
268268
for string, rather than leaking memory if someone else
@@ -350,7 +350,10 @@ s_stab_generic (int what,
350350
This must be done before creating symbols below, which uses
351351
the notes obstack. */
352352
if (saved_string_obstack_end == obstack_next_free (&notes))
353-
obstack_free (&notes, string);
353+
{
354+
obstack_free (&notes, string);
355+
saved_string_obstack_end = NULL;
356+
}
354357

355358
/* At least for now, stabs in a special stab section are always
356359
output as 12 byte blocks of information. */
@@ -398,6 +401,7 @@ s_stab_generic (int what,
398401
out:
399402
if (saved_string_obstack_end == obstack_next_free (&notes))
400403
obstack_free (&notes, string);
404+
out2:
401405
subseg_set (saved_seg, saved_subseg);
402406
}
403407

0 commit comments

Comments
 (0)