Remove unused code in s_security.cpp (#4172)
Note that the macro CHECK_FILE_ERR implements the code removedmaster
parent
d499ec4838
commit
a9bc7dc405
|
@ -249,8 +249,8 @@ bool ScriptApiSecurity::isSecure(lua_State *L)
|
||||||
|
|
||||||
#define CHECK_FILE_ERR(ret, fp) \
|
#define CHECK_FILE_ERR(ret, fp) \
|
||||||
if (ret) { \
|
if (ret) { \
|
||||||
if (fp) std::fclose(fp); \
|
|
||||||
lua_pushfstring(L, "%s: %s", path, strerror(errno)); \
|
lua_pushfstring(L, "%s: %s", path, strerror(errno)); \
|
||||||
|
if (fp) std::fclose(fp); \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,20 +291,12 @@ bool ScriptApiSecurity::safeLoadFile(lua_State *L, const char *path)
|
||||||
// Read the file
|
// Read the file
|
||||||
int ret = std::fseek(fp, 0, SEEK_END);
|
int ret = std::fseek(fp, 0, SEEK_END);
|
||||||
CHECK_FILE_ERR(ret, fp);
|
CHECK_FILE_ERR(ret, fp);
|
||||||
if (ret) {
|
|
||||||
std::fclose(fp);
|
|
||||||
lua_pushfstring(L, "%s: %s", path, strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
size_t size = std::ftell(fp) - start;
|
size_t size = std::ftell(fp) - start;
|
||||||
char *code = new char[size];
|
char *code = new char[size];
|
||||||
ret = std::fseek(fp, start, SEEK_SET);
|
ret = std::fseek(fp, start, SEEK_SET);
|
||||||
CHECK_FILE_ERR(ret, fp);
|
CHECK_FILE_ERR(ret, fp);
|
||||||
if (ret) {
|
|
||||||
std::fclose(fp);
|
|
||||||
lua_pushfstring(L, "%s: %s", path, strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
size_t num_read = std::fread(code, 1, size, fp);
|
size_t num_read = std::fread(code, 1, size, fp);
|
||||||
if (path) {
|
if (path) {
|
||||||
std::fclose(fp);
|
std::fclose(fp);
|
||||||
|
|
Loading…
Reference in New Issue