Ensure that we can seek in the file in js_loadfile.

This commit is contained in:
Tor Andersson
2014-01-10 16:55:36 +01:00
parent effc3ae9ad
commit 7e40d3fefd
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -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);
+1 -1
View File
@@ -52,8 +52,8 @@ enum
EXP_NEG,
EXP_BITNOT,
EXP_LOGNOT,
EXP_LOGOR,
EXP_LOGOR,
EXP_LOGAND,
EXP_BITOR,
EXP_BITXOR,