Skip to content

Commit 0f04103

Browse files
authored
Merge pull request #827 from yamt/fix-segv-no-arg
native runtime: fix a NULL dereference
2 parents 0b67969 + 6f0dc35 commit 0f04103

File tree

1 file changed

+4
-0
lines changed
  • runtimes/native/src/backend

1 file changed

+4
-0
lines changed

runtimes/native/src/backend/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,14 @@ int main (int argc, const char* argv[]) {
127127

128128
if (argc < 2) {
129129
FILE* file = fopen(argv[0], "rb");
130+
if (file == NULL) {
131+
goto usage;
132+
}
130133
fseek(file, -sizeof(FileFooter), SEEK_END);
131134

132135
FileFooter footer;
133136
if (fread(&footer, 1, sizeof(FileFooter), file) < sizeof(FileFooter) || footer.magic != 1414676803) {
137+
usage:
134138
// No bundled cart found
135139
fprintf(stderr, "Usage: wasm4 <cart>\n");
136140
return 1;

0 commit comments

Comments
 (0)