From af6cbc48d16c721a286dba0fd22521624b1d8a52 Mon Sep 17 00:00:00 2001 From: Shinichiro Hamaji Date: Wed, 1 Apr 2009 02:22:20 +0900 Subject: [PATCH] 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. --- tcc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tcc.c b/tcc.c index e483d92..9da8260 100644 --- a/tcc.c +++ b/tcc.c @@ -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(); }