summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-24 21:56:45 +0200
committerwm4 <wm4@nowhere>2014-10-24 21:57:06 +0200
commitef252b2314474ff29a58674abc3d564ec36162e4 (patch)
treea92e6d23f054066076d8c76d3d8581bb863c04ae /player
parent55e3dab7ebd707a94995696aa1098725f3c35521 (diff)
downloadmpv-ef252b2314474ff29a58674abc3d564ec36162e4.tar.bz2
mpv-ef252b2314474ff29a58674abc3d564ec36162e4.tar.xz
lua: lua_tostring() on an error value can return NULL
Lua is so clever it allows values that can't be converted to strings, in which case lua_tostring() returns NULL. Trigger undefined behavior.
Diffstat (limited to 'player')
-rw-r--r--player/lua.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/player/lua.c b/player/lua.c
index 791a7d4fea..80d40e1b6a 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -346,8 +346,10 @@ static int run_lua(lua_State *L)
// run this under an error handler that can do backtraces
lua_pushcfunction(L, error_handler); // errf
lua_pushcfunction(L, load_scripts); // errf fn
- if (lua_pcall(L, 0, 0, -2)) // errf [error]
- MP_FATAL(ctx, "Lua error: %s\n", lua_tostring(L, -1));
+ if (lua_pcall(L, 0, 0, -2)) { // errf [error]
+ const char *e = lua_tostring(L, -1);
+ MP_FATAL(ctx, "Lua error: %s\n", e ? e : "(unknown)");
+ }
return 0;
}