From a2d0038045233a1830c61c4816304c33e2f92087 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 5 Oct 2018 16:57:47 -0500 Subject: [PATCH] widl: Check for positive array dimension when parsing array. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- tools/widl/parser.y | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 53a5ec01311..3b99d939d1a 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -468,8 +468,8 @@ arg: attributes decl_spec m_any_declarator { if ($2->stgclass != STG_NONE && $ ; array: '[' expr ']' { $$ = $2; - if (!$$->is_const) - error_loc("array dimension is not an integer constant\n"); + if (!$$->is_const || $$->cval <= 0) + error_loc("array dimension is not a positive integer constant\n"); } | '[' '*' ']' { $$ = make_expr(EXPR_VOID); } | '[' ']' { $$ = make_expr(EXPR_VOID); } @@ -1554,9 +1554,6 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl { if (dim->is_const) { - if (dim->cval <= 0) - error_loc("%s: array dimension must be positive\n", v->name); - /* FIXME: should use a type_memsize that allows us to pass in a pointer size */ if (0) {