Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when QuitGap is called while reading from an InputTextString #4823

Merged
merged 1 commit into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,14 @@ static Int GetLine2(TypInputFile * input)
if (input->sline == 0 ||
(IS_STRING_REP(input->sline) &&
GET_LEN_STRING(input->sline) <= input->spos)) {
input->sline = CALL_1ARGS( ReadLineFunc, input->stream );
// If we are in the process of quitting, we cannot call
// GAP functions, so we just return EOF.
if (STATE(UserHasQuit) || STATE(UserHasQUIT)) {
input->sline = Fail;
}
else {
input->sline = CALL_1ARGS(ReadLineFunc, input->stream);
}
input->spos = 0;
}
if ( input->sline == Fail || ! IS_STRING(input->sline) ) {
Expand Down
2 changes: 2 additions & 0 deletions tst/testspecial/error-in-InputTextString.g
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
READ_NORECOVERY(InputTextString("Print(1 + [()]);"));
quit;
9 changes: 9 additions & 0 deletions tst/testspecial/error-in-InputTextString.g.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
gap> READ_NORECOVERY(InputTextString("Print(1 + [()]);"));
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `+' on 2 arguments at GAPROOT/lib/methsel2.g:LINE called from
<function "HANDLE_METHOD_NOT_FOUND">( <arguments> )
called from read-eval loop at stream:1
type 'quit;' to quit to outer loop
brk> quit;
fail
gap> QUIT;
1 change: 1 addition & 0 deletions tst/testspecial/exit-in-InputTextString.g
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
READ_NORECOVERY(InputTextString("Print(QuitGap(0));"));
1 change: 1 addition & 0 deletions tst/testspecial/exit-in-InputTextString.g.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gap> READ_NORECOVERY(InputTextString("Print(QuitGap(0));"));