From 2361ec35aa2438cb6c4e9976eecc856d3b123447 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 24 Sep 2016 17:52:36 +0200 Subject: lua: fix array detection This was dumb and could return something like "{name=123}" as an array. Also, fix the error message if a key is not a string. lua_typename() takes a type directly, not a stack item. --- player/lua.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'player/lua.c') diff --git a/player/lua.c b/player/lua.c index 8bf8f2b590..1ad6bff682 100644 --- a/player/lua.c +++ b/player/lua.c @@ -709,7 +709,7 @@ static void makenode(void *tmp, mpv_node *dst, lua_State *L, int t) bool empty = lua_isnil(L, -1); // t[n] lua_pop(L, 1); // - if (empty) { - count = n; + count = n - 1; break; } } @@ -751,7 +751,7 @@ static void makenode(void *tmp, mpv_node *dst, lua_State *L, int t) makenode(tmp, &list->values[list->num], L, -1); if (lua_type(L, -2) != LUA_TSTRING) { luaL_error(L, "key must be a string, but got %s", - lua_typename(L, -2)); + lua_typename(L, lua_type(L, -2))); } list->keys[list->num] = talloc_strdup(tmp, lua_tostring(L, -2)); list->num++; -- cgit v1.2.3