Skip to content

Commit 012d2cc

Browse files
committed
Overflow checks: handle NULL expression passed to cConstIntExprRanged()
- if there was some other error parsing the CASE expression, expression could be NULL
1 parent ee0b957 commit 012d2cc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/compiler/parser-decl-symbtype.bas

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,20 @@ function cConstIntExprRanged _
6363

6464
r = @range( typeGetSizeType( todtype ) )
6565

66+
if( expr = NULL ) then
67+
errReport( FB_ERRMSG_EXPECTEDEXPRESSION )
68+
expr = astNewCONSTi( 0, todtype )
69+
end if
70+
71+
if( astIsCONST( expr ) = FALSE ) then
72+
errReport( FB_ERRMSG_EXPECTEDCONST )
73+
astDelTree( expr )
74+
expr = astNewCONSTi( 0, FB_DATATYPE_LONGINT )
75+
end if
76+
6677
dtype = astGetDataType( expr )
6778

68-
'' cConstIntExpr() will flush expr
69-
value = cConstIntExpr( expr, FB_DATATYPE_LONGINT )
79+
value = astConstFlushToInt( expr, FB_DATATYPE_LONGINT )
7080

7181
if( typeIsSigned( dtype ) ) then
7282
if( typeIsSigned( todtype ) ) then

0 commit comments

Comments
 (0)