diff options
-rw-r--r-- | engines/hdb/lua-script.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp index 7a33355710..b563de3d0e 100644 --- a/engines/hdb/lua-script.cpp +++ b/engines/hdb/lua-script.cpp @@ -1256,8 +1256,21 @@ static int dofile(lua_State *L) { if (!in) error("Lua dofile: cannot open file '%s'", fName); + int length = in->size(); + char *chunk = new char[length + 1]; + in->read((void *)chunk, length); + + chunk[length] = '\0'; // be on the safe side + + Common::String chunkString(chunk); + delete[] chunk; + delete in; + if (!g_hdb->_lua->executeChunk(chunkString, fName)) { + return 0; + } + return 0; } |