mirror of
https://github.com/open-simh/simtools.git
synced 2026-05-01 22:05:56 +00:00
Fix a use-after-free. Found by Don North.
Also adjust test case to include this code. Fixes #2.
This commit is contained in:
@@ -469,13 +469,15 @@ static int assemble(
|
|||||||
}
|
}
|
||||||
|
|
||||||
my_searchenv(name, "INCLUDE", hitfile, sizeof(hitfile));
|
my_searchenv(name, "INCLUDE", hitfile, sizeof(hitfile));
|
||||||
free(name);
|
|
||||||
|
|
||||||
if (hitfile[0] == '\0') {
|
if (hitfile[0] == '\0') {
|
||||||
report(stack->top, "Unable to find .INCLUDE file \"%s\"\n", name);
|
report(stack->top, "Unable to find .INCLUDE file \"%s\"\n", name);
|
||||||
|
free(name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(name);
|
||||||
|
|
||||||
incl = new_file_stream(hitfile);
|
incl = new_file_stream(hitfile);
|
||||||
if (incl == NULL) {
|
if (incl == NULL) {
|
||||||
report(stack->top, "Unable to open .INCLUDE file \"%s\"\n", hitfile);
|
report(stack->top, "Unable to open .INCLUDE file \"%s\"\n", hitfile);
|
||||||
|
|||||||
@@ -48,7 +48,12 @@ test-include.mac:15: ***ERROR Bad .INCLUDE file name
|
|||||||
16 .include =incl.mac= ; looks like assignment
|
16 .include =incl.mac= ; looks like assignment
|
||||||
test-include.mac:17: ***ERROR Invalid expression
|
test-include.mac:17: ***ERROR Invalid expression
|
||||||
17 000012 000000G 000000 .include :incl.mac: ; looks like a label
|
17 000012 000000G 000000 .include :incl.mac: ; looks like a label
|
||||||
17
|
18
|
||||||
|
19 ; this is an error: file does not existst
|
||||||
|
20
|
||||||
|
test-include.mac:21: ***ERROR Unable to find .INCLUDE file "does-not-exist.mac"
|
||||||
|
21 .include "does-not-exist.mac"
|
||||||
|
21
|
||||||
|
|
||||||
|
|
||||||
Symbol table
|
Symbol table
|
||||||
|
|||||||
@@ -15,3 +15,7 @@
|
|||||||
.include <incl.mac<
|
.include <incl.mac<
|
||||||
.include =incl.mac= ; looks like assignment
|
.include =incl.mac= ; looks like assignment
|
||||||
.include :incl.mac: ; looks like a label
|
.include :incl.mac: ; looks like a label
|
||||||
|
|
||||||
|
; this is an error: file does not existst
|
||||||
|
|
||||||
|
.include "does-not-exist.mac"
|
||||||
|
|||||||
Reference in New Issue
Block a user