From 4443e83b75b36946e8a35fd0dfebbb93c396c1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Van=20Canneyt?= Date: Wed, 31 Jan 2024 13:47:17 +0100 Subject: [PATCH] * replace/restore_scanner use var in state to make sure the correct scanner is freed --- compiler/symcreat.pas | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/symcreat.pas b/compiler/symcreat.pas index e750984b8a..34422c3308 100644 --- a/compiler/symcreat.pas +++ b/compiler/symcreat.pas @@ -35,6 +35,7 @@ interface type tscannerstate = record + new_scanner: tscannerfile; old_scanner: tscannerfile; old_filepos: tfileposinfo; old_token: ttoken; @@ -166,7 +167,8 @@ implementation { creating a new scanner resets the block type, while we want to continue in the current one } old_block_type:=block_type; - current_scanner:=tscannerfile.Create('_Macro_.'+tempname,true); + sstate.new_scanner:=tscannerfile.Create('_Macro_.'+tempname,true); + set_current_scanner(sstate.new_scanner,False); block_type:=old_block_type; { required for e.g. FpcDeepCopy record method (uses "out" parameter; field names are escaped via &, so should not cause conflicts } @@ -178,8 +180,8 @@ implementation begin if sstate.valid then begin - current_scanner.free; - current_scanner:=sstate.old_scanner; + sstate.new_scanner.free; + set_current_scanner(sstate.old_scanner,false); current_filepos:=sstate.old_filepos; token:=sstate.old_token; current_settings.modeswitches:=sstate.old_modeswitches;