diff options
author | wm4 <wm4@nowhere> | 2016-09-24 17:52:36 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-09-24 17:52:36 +0200 |
commit | 2361ec35aa2438cb6c4e9976eecc856d3b123447 (patch) | |
tree | 4a8d87fe36f1acd5dd70822b6c04b9ebc6ad2051 /player/lua.c | |
parent | 68d2903cb1f3095070636ebb9e696594cc71f6c4 (diff) | |
download | mpv-2361ec35aa2438cb6c4e9976eecc856d3b123447.tar.bz2 mpv-2361ec35aa2438cb6c4e9976eecc856d3b123447.tar.xz |
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.
Diffstat (limited to 'player/lua.c')
-rw-r--r-- | player/lua.c | 4 |
1 files changed, 2 insertions, 2 deletions
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++; |