Fix overrun in decl_initializer_alloc.

This bug was reported on

http://lists.gnu.org/archive/html/tinycc-devel/2009-03/msg00035.html

This happens because parser of array initializer doesn't stop to read until semi-colon or comma.
This commit is contained in:
Shinichiro Hamaji 2009-04-01 02:22:20 +09:00 committed by grischka
parent 040ef000e4
commit af6cbc48d1

6
tcc.c
View File

@ -9176,9 +9176,11 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
if (tok == '{')
level++;
else if (tok == '}') {
if (level == 0)
break;
level--;
if (level <= 0) {
next();
break;
}
}
next();
}