From: Vsevolod Stakhov Date: Tue, 13 Aug 2024 14:07:06 +0000 (+0100) Subject: [Fix] Make tostring in UCL a bit less brain-damaged X-Git-Tag: 3.10.0~37^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ec9f02eb9fa2faf60873547a14b758240289398;p=thirdparty%2Frspamd.git [Fix] Make tostring in UCL a bit less brain-damaged --- diff --git a/contrib/libucl/lua_ucl.c b/contrib/libucl/lua_ucl.c index 3e3a066056..79c6586159 100644 --- a/contrib/libucl/lua_ucl.c +++ b/contrib/libucl/lua_ucl.c @@ -1146,8 +1146,9 @@ lua_ucl_object_tostring(lua_State *L) enum ucl_emitter format = UCL_EMIT_JSON_COMPACT; obj = lua_ucl_object_get(L, 1); + int type = ucl_object_type(obj); - if (obj) { + if (type == UCL_ARRAY || type == UCL_OBJECT) { if (lua_gettop(L) > 1) { if (lua_type(L, 2) == LUA_TSTRING) { const char *strtype = lua_tostring(L, 2); @@ -1158,9 +1159,12 @@ lua_ucl_object_tostring(lua_State *L) return lua_ucl_to_string(L, obj, format); } - else { + else if (type == UCL_NULL) { lua_pushnil(L); } + else { + ucl_object_lua_push_scalar(L, obj, 0); + } return 1; }