Skip to content

Commit

Permalink
Fix regression in lua_load path handling
Browse files Browse the repository at this point in the history
This should resolve #1778 (and similar issues).
  • Loading branch information
brndnmtthws committed Mar 10, 2024
1 parent 2638444 commit 755e8c3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/llua.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,18 @@ inline bool file_exists(const char *path) {
void llua_load(const char *script) {
int error;

if (!file_exists(script)) {
NORM_ERR("llua_load: specified script file '%s' doesn't exist", script);
std::string path = to_real_path(script);

if (!file_exists(path.c_str())) {
NORM_ERR("llua_load: specified script file '%s' doesn't exist",
path.c_str());
// return without initializing lua_L because other parts of the code rely
// on it being null if the script is not loaded
return;
}

llua_init();

std::string path = to_real_path(script);
error = luaL_dofile(lua_L, path.c_str());
if (error != 0) {
NORM_ERR("llua_load: %s", lua_tostring(lua_L, -1));
Expand Down

0 comments on commit 755e8c3

Please sign in to comment.