* do not crash in case of too many $push directives, resolves #39652

This commit is contained in:
florian 2022-04-07 22:51:30 +02:00
parent 92a0640bcc
commit 54dccaaad1
2 changed files with 27 additions and 18 deletions

View File

@ -1204,24 +1204,26 @@ unit scandir;
begin begin
if switchesstatestackpos < 1 then if switchesstatestackpos < 1 then
Message(scan_e_too_many_pop); Message(scan_e_too_many_pop)
else
Dec(switchesstatestackpos); begin
recordpendinglocalfullswitch(switchesstatestack[switchesstatestackpos].localsw); Dec(switchesstatestackpos);
recordpendingverbosityfullswitch(switchesstatestack[switchesstatestackpos].verbosity); recordpendinglocalfullswitch(switchesstatestack[switchesstatestackpos].localsw);
recordpendingalignmentfullswitch(switchesstatestack[switchesstatestackpos].alignment); recordpendingverbosityfullswitch(switchesstatestack[switchesstatestackpos].verbosity);
recordpendingpackenum(switchesstatestack[switchesstatestackpos].packenum); recordpendingalignmentfullswitch(switchesstatestack[switchesstatestackpos].alignment);
recordpendingpackrecords(switchesstatestack[switchesstatestackpos].packrecords); recordpendingpackenum(switchesstatestack[switchesstatestackpos].packenum);
recordpendingsetalloc(switchesstatestack[switchesstatestackpos].setalloc); recordpendingpackrecords(switchesstatestack[switchesstatestackpos].packrecords);
pendingstate.nextmessagerecord:=switchesstatestack[switchesstatestackpos].pmessage; recordpendingsetalloc(switchesstatestack[switchesstatestackpos].setalloc);
{ Reset verbosity and forget previous pmeesage } pendingstate.nextmessagerecord:=switchesstatestack[switchesstatestackpos].pmessage;
RestoreLocalVerbosity(nil); { Reset verbosity and forget previous pmeesage }
current_settings.pmessage:=nil; RestoreLocalVerbosity(nil);
{ Do not yet activate these changes, as otherwise current_settings.pmessage:=nil;
you get problem idf you put a $pop just right after { Do not yet activate these changes, as otherwise
a addition for instance fro which you explicitly truned the overflow check you get problem idf you put a $pop just right after
out by using $Q- after a $push PM 2012-08-29 } a addition for instance fro which you explicitly truned the overflow check
// flushpendingswitchesstate; out by using $Q- after a $push PM 2012-08-29 }
// flushpendingswitchesstate;
end;
end; end;
procedure dir_pointermath; procedure dir_pointermath;

7
tests/webtbf/tw39652.pp Normal file
View File

@ -0,0 +1,7 @@
{ %fail }
program onepoptoomanycrash;
{$PUSH}
{$POP}
{$POP}
begin
end.