Skip to content

Commit f6dd943

Browse files
committed
ielr: fix crash on memory management
Reported by Dwight Guth. https://lists.gnu.org/r/bug-bison/2020-06/msg00037.html * src/AnnotationList.c (AnnotationList__computePredecessorAnnotations): Beware that SBITSET__FOR_EACH nests _two_ for-loops, so "break" does not actually break out of it. That was the only occurrence in the code. * src/Sbitset.h (SBITSET__FOR_EACH): Warn passersby.
1 parent 8f44164 commit f6dd943

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

THANKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Di-an Jan [email protected]
5959
Dick Streefland [email protected]
6060
Didier Godefroy [email protected]
6161
Don Macpherson [email protected]
62+
Dwight Guth [email protected]
6263
6364
Enrico Scholz [email protected]
6465

src/AnnotationList.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ AnnotationList__computePredecessorAnnotations (
276276
obstack_free (annotations_obstackp,
277277
annotation_node->contributions[ci]);
278278
annotation_node->contributions[ci] = NULL;
279-
break;
279+
// "Break" out of SBITSET__FOR_EACH.
280+
goto after_sbitset__for_each;
280281
}
281282
else
282283
{
@@ -309,6 +310,7 @@ AnnotationList__computePredecessorAnnotations (
309310
predecessor_item);
310311
}
311312
}
313+
after_sbitset__for_each:;
312314
}
313315
if (annotation_node->contributions[ci])
314316
{

src/Sbitset.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ void Sbitset__fprint (Sbitset self, Sbitset__Index nbits, FILE *file);
8181
*ptr_self = *ptr_other1 | *ptr_other2; \
8282
} while (0)
8383

84+
/* ATTENTION: there are *two* loops here, "break" and "continue" will
85+
not apply to the whole loop, just the inner one. */
8486
# define SBITSET__FOR_EACH(SELF, NBITS, ITER, INDEX) \
8587
for ((ITER) = (SELF); (ITER) < (SELF) + Sbitset__nbytes (NBITS); ++(ITER)) \
8688
if (*(ITER) != 0) \

0 commit comments

Comments
 (0)