From ee17493d470ae7fd7b34241f263cfa6d790ce1b3 Mon Sep 17 00:00:00 2001 From: Christian Storm Date: Tue, 21 May 2019 14:45:51 +0200 Subject: [PATCH] Lua: fix segfault in image property handling table2image() calls lua_dump_table() with the 'key' parameter being NULL and the 'img' parameter set. Subsequently, dict_insert_value() is called with key == NULL if the Lua stack key's type is string or number, segfaulting SWUpdate. Signed-off-by: Christian Storm Reported-by: Akihiro Suzuki Acked-by: Stefano Babic [Backported from: ee17493d470ae7fd7b34241f263cfa6d790ce1b3] Signed-off-by: Pierre-Jean Texier --- corelib/lua_interface.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index d4ebe4a..443f149 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -80,11 +80,11 @@ static void lua_dump_table(lua_State *L, char *str, struct img_type *img, const lua_tostring(L, -1), lua_tostring(L, -2)); if (img) { - TRACE("Inserting property %s[%s] = %s", - key, - lua_tostring(L, -1), + TRACE("Inserting property %s = %s", + key ? key : lua_tostring(L, -1), lua_tostring(L, -2)); - dict_insert_value(&img->properties, key, + dict_insert_value(&img->properties, + key ? key : lua_tostring(L, -1), lua_tostring(L, -2)); } break; -- 2.7.4