From 81c6a6389873d58795a9b75a8b39f38dd32f850f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 25 Nov 2022 09:51:58 +1300 Subject: Fix undefined behaviour in parser Fix undefined behaviour in swig's parser when handling default parameter expressions containing method calls. Fixes #2447 --- Source/CParse/parser.y | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Source') diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 61fac2b2e..7b5df73ee 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -6582,7 +6582,7 @@ exprmem : ID ARROW ID { $$.type = 0; } | ID ARROW ID LPAREN callparms RPAREN { - $$.val = NewStringf("%s->%s(%s)", $1, $3, $5); + $$.val = NewStringf("%s->%s(%s)", $1, $3, $5.val); $$.type = 0; } | exprmem ARROW ID { @@ -6591,14 +6591,14 @@ exprmem : ID ARROW ID { } | exprmem ARROW ID LPAREN callparms RPAREN { $$ = $1; - Printf($$.val, "->%s(%s)", $3, $5); + Printf($$.val, "->%s(%s)", $3, $5.val); } | ID PERIOD ID { $$.val = NewStringf("%s.%s", $1, $3); $$.type = 0; } | ID PERIOD ID LPAREN callparms RPAREN { - $$.val = NewStringf("%s.%s(%s)", $1, $3, $5); + $$.val = NewStringf("%s.%s(%s)", $1, $3, $5.val); $$.type = 0; } | exprmem PERIOD ID { @@ -6607,7 +6607,7 @@ exprmem : ID ARROW ID { } | exprmem PERIOD ID LPAREN callparms RPAREN { $$ = $1; - Printf($$.val, ".%s(%s)", $3, $5); + Printf($$.val, ".%s(%s)", $3, $5.val); } ; -- cgit v1.2.1