goto :eof in a subroutine makes a heap corruption
Closed this issue · 2 comments
Deleted user commented
This code:
call test
goto :eof
:test
goto :eof
Makes Yori crash with exit code 3221226356
(A heap has been corrupted.
)
In CMD this does the same as exit /b 0
and Yori's return 0
Probably something with this code:
Lines 314 to 326 in 41640e1
malxau commented
Thanks for the report. I think it's just that I don't remember my own conventions. It's trying to iterate through all open subroutine contexts and free them, but to do that it needs to specify the list head to know when to terminate (as opposed to any arbitrary list element where it will return the list head as a valid element.)
diff --git a/builtins/ys.c b/builtins/ys.c
index 4552ad3..68c0669 100644
--- a/builtins/ys.c
+++ b/builtins/ys.c
@@ -1195,7 +1195,7 @@ YsFreeScript(
NextEntry = YoriLibGetNextListEntry(&Script->CallStackLinks, NULL);
while(NextEntry != NULL) {
StackLocation = CONTAINING_RECORD(NextEntry, YS_CALL_STACK, StackLinks);
- NextEntry = YoriLibGetNextListEntry(&StackLocation->StackLinks, NextEntry);
+ NextEntry = YoriLibGetNextListEntry(&Script->CallStackLinks, NextEntry);
YsFreeCallStack(StackLocation);
CallStackFound = TRUE;
malxau commented
This should be fixed in 1.50, released today. Please let me know if there are further related issues.