diff options
author | Zeno- <kde.psych@gmail.com> | 2016-05-30 22:37:40 +1000 |
---|---|---|
committer | Zeno- <kde.psych@gmail.com> | 2016-05-30 22:37:40 +1000 |
commit | a9bc7dc405df04d5a3cb5fe5de43190200dc692d (patch) | |
tree | 9c65d7c878a1e547ba243dbdc7bbac68fcadeadf /src/script/cpp_api/s_security.cpp | |
parent | d499ec483837fa7210176ef39beba2d5a3a5a61d (diff) | |
download | minetest-a9bc7dc405df04d5a3cb5fe5de43190200dc692d.tar.gz minetest-a9bc7dc405df04d5a3cb5fe5de43190200dc692d.tar.bz2 minetest-a9bc7dc405df04d5a3cb5fe5de43190200dc692d.zip |
Remove unused code in s_security.cpp (#4172)
Note that the macro CHECK_FILE_ERR implements the code removed
Diffstat (limited to 'src/script/cpp_api/s_security.cpp')
-rw-r--r-- | src/script/cpp_api/s_security.cpp | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/script/cpp_api/s_security.cpp b/src/script/cpp_api/s_security.cpp index 730235c7b..e117a4811 100644 --- a/src/script/cpp_api/s_security.cpp +++ b/src/script/cpp_api/s_security.cpp @@ -249,8 +249,8 @@ bool ScriptApiSecurity::isSecure(lua_State *L) #define CHECK_FILE_ERR(ret, fp) \ if (ret) { \ - if (fp) std::fclose(fp); \ lua_pushfstring(L, "%s: %s", path, strerror(errno)); \ + if (fp) std::fclose(fp); \ return false; \ } @@ -291,20 +291,12 @@ bool ScriptApiSecurity::safeLoadFile(lua_State *L, const char *path) // Read the file int ret = std::fseek(fp, 0, SEEK_END); 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; char *code = new char[size]; ret = std::fseek(fp, start, SEEK_SET); 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); if (path) { std::fclose(fp); |