From 5b91f8985210b2203c4feba1092804eea65da500 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 25 Oct 2014 17:20:25 +0200 Subject: [PATCH] lua: fix some more lua_tostring() mistakes Why can't it just raise an error? --- player/lua.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/player/lua.c b/player/lua.c index 80d40e1b6a..561ba37487 100644 --- a/player/lua.c +++ b/player/lua.c @@ -161,7 +161,7 @@ static int error_handler(lua_State *L) if (luaL_loadstring(L, "return debug.traceback('', 3)") == 0) { // e fn|err lua_call(L, 0, 1); // e backtrace const char *tr = lua_tostring(L, -1); - MP_WARN(ctx, "%s\n", tr); + MP_WARN(ctx, "%s\n", tr ? tr : "(unknown)"); } lua_pop(L, 1); // e @@ -1201,6 +1201,8 @@ static int script_subprocess(lua_State *L) lua_pushinteger(L, n + 1); // args n lua_gettable(L, -2); // args arg args[n] = talloc_strdup(tmp, lua_tostring(L, -1)); + if (!args[n]) + luaL_error(L, "program arguments must be strings"); lua_pop(L, 1); // args } args[num_args] = NULL;