Skip to content

Commit a9bc7dc

Browse files
committedMay 30, 2016
Remove unused code in s_security.cpp (#4172)
Note that the macro CHECK_FILE_ERR implements the code removed
1 parent d499ec4 commit a9bc7dc

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed
 

Diff for: ‎src/script/cpp_api/s_security.cpp

+3-11
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ bool ScriptApiSecurity::isSecure(lua_State *L)
249249

250250
#define CHECK_FILE_ERR(ret, fp) \
251251
if (ret) { \
252-
if (fp) std::fclose(fp); \
253252
lua_pushfstring(L, "%s: %s", path, strerror(errno)); \
253+
if (fp) std::fclose(fp); \
254254
return false; \
255255
}
256256

@@ -291,20 +291,12 @@ bool ScriptApiSecurity::safeLoadFile(lua_State *L, const char *path)
291291
// Read the file
292292
int ret = std::fseek(fp, 0, SEEK_END);
293293
CHECK_FILE_ERR(ret, fp);
294-
if (ret) {
295-
std::fclose(fp);
296-
lua_pushfstring(L, "%s: %s", path, strerror(errno));
297-
return false;
298-
}
294+
299295
size_t size = std::ftell(fp) - start;
300296
char *code = new char[size];
301297
ret = std::fseek(fp, start, SEEK_SET);
302298
CHECK_FILE_ERR(ret, fp);
303-
if (ret) {
304-
std::fclose(fp);
305-
lua_pushfstring(L, "%s: %s", path, strerror(errno));
306-
return false;
307-
}
299+
308300
size_t num_read = std::fread(code, 1, size, fp);
309301
if (path) {
310302
std::fclose(fp);

0 commit comments

Comments
 (0)
Please sign in to comment.