From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 6E58B46971A for ; Tue, 3 Dec 2019 15:53:21 +0300 (MSK) Date: Tue, 3 Dec 2019 15:53:15 +0300 From: Nikita Pettik Message-ID: <20191203125315.GA15510@tarantool.org> References: <20191129213624.35735-1-maria.khaydich@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191129213624.35735-1-maria.khaydich@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH] Stack use after scope List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Maria Cc: tarantool-patches@dev.tarantool.org On 30 Nov 00:36, Maria wrote: > Json decode method allocated serializer struct on stack and referenced > it after scope. > > Thanks to @Korablev77 for the initial investigation. A bit extended commit message and pushed to master and backported to 1.10 and 2.2 as obvious. > Closes #4637 > --- > third_party/lua-cjson/lua_cjson.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/third_party/lua-cjson/lua_cjson.c b/third_party/lua-cjson/lua_cjson.c > index 3d7edbf28..3d25814f3 100644 > --- a/third_party/lua-cjson/lua_cjson.c > +++ b/third_party/lua-cjson/lua_cjson.c > @@ -1005,10 +1005,10 @@ static int json_decode(lua_State *l) > "expected 1 or 2 arguments"); > > if (lua_gettop(l) == 2) { > - struct luaL_serializer user_cfg = *luaL_checkserializer(l); > - luaL_serializer_parse_options(l, &user_cfg); > + struct luaL_serializer *user_cfg = luaL_checkserializer(l); > + luaL_serializer_parse_options(l, user_cfg); > lua_pop(l, 1); > - json.cfg = &user_cfg; > + json.cfg = user_cfg; > } else { > json.cfg = luaL_checkserializer(l); > } > -- > 2.20.1 (Apple Git-117) >