mirror of
https://github.com/ccxvii/mujs.git
synced 2026-09-21 14:43:34 +08:00
Ensure that we can seek in the file in js_loadfile.
This commit is contained in:
@@ -25,10 +25,14 @@ int js_loadfile(js_State *J, const char *filename)
|
||||
int n, t;
|
||||
|
||||
f = fopen(filename, "r");
|
||||
if (!f)
|
||||
if (!f) {
|
||||
return js_error(J, "cannot open file: '%s'", filename);
|
||||
}
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
if (fseek(f, 0, SEEK_END) < 0) {
|
||||
fclose(f);
|
||||
return js_error(J, "cannot seek in file: '%s'", filename);
|
||||
}
|
||||
n = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user