aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-08-08 14:02:45 -0700
committerGuy Harris <guy@alum.mit.edu>2017-08-08 21:03:25 +0000
commitae3fd56b20b1e1c0b2b9871827ed2f3529576717 (patch)
tree0c6aa2e58a44fe26bc8ed2f5d83b602231856381
parent6d8f3ddc7c0147f0a316b53ce3c5f852d5eb5921 (diff)
Check for errors running the Lua scripts.
Also, fix error messages reported for lua_load() to speak of precompilation, not execution (the script isn't *executed* until lua_pcall() is called). Change-Id: I7ac9ee6e5df7612f9af141e51958fbfad38a4083 Reviewed-on: https://code.wireshark.org/review/23023 Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--epan/wslua/init_wslua.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c
index ce60aa8644..cfb71c739d 100644
--- a/epan/wslua/init_wslua.c
+++ b/epan/wslua/init_wslua.c
@@ -546,28 +546,28 @@ static gboolean lua_load_script(const gchar* filename, const gchar* dirname, con
#endif
switch (error) {
- case 0:
+ case 0: /* LUA_OK */
if (dirname) {
set_file_environment(filename, dirname);
}
if (file_count > 0) {
numargs = lua_script_push_args(file_count);
}
- lua_pcall(L,numargs,0,1);
+ error = lua_pcall(L,numargs,0,1);
fclose(file);
lua_pop(L,1); /* pop the error handler */
- return TRUE;
+ return error ? FALSE : TRUE;
case LUA_ERRSYNTAX: {
report_failure("Lua: syntax error during precompilation of `%s':\n%s",filename,lua_tostring(L,-1));
fclose(file);
return FALSE;
}
case LUA_ERRMEM:
- report_failure("Lua: memory allocation error during execution of %s",filename);
+ report_failure("Lua: memory allocation error during precompilation of %s",filename);
fclose(file);
return FALSE;
default:
- report_failure("Lua: unknown error during execution of %s: %d",filename,error);
+ report_failure("Lua: unknown error during precompilation of %s: %d",filename,error);
fclose(file);
return FALSE;
}