From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 2F4DF25F71 for ; Thu, 8 Aug 2019 10:12:27 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OTq7tHR9WFtN for ; Thu, 8 Aug 2019 10:12:27 -0400 (EDT) Received: from smtp45.i.mail.ru (smtp45.i.mail.ru [94.100.177.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id D7FBB25363 for ; Thu, 8 Aug 2019 10:12:26 -0400 (EDT) Received: from [185.6.245.156] (port=59703 helo=localhost.localdomain) by smtp45.i.mail.ru with esmtpa (envelope-from ) id 1hvj9V-0003pa-2H for tarantool-patches@freelists.org; Thu, 08 Aug 2019 17:12:25 +0300 From: sergos@tarantool.org Subject: [tarantool-patches] [PATCH] luajit: fox for debug.getinfo(1,'>S') Date: Thu, 8 Aug 2019 14:12:22 +0000 Message-Id: <20190808141222.79226-1-sergos@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org fix for the debug machinery in case an extra argument is expected on Lua stack Fixes: #3833 https://github.com/tarantool/luajit/tree/sergos/luajit-gh-509-debug-getinfo-crash --- src/lj_debug.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lj_debug.c b/src/lj_debug.c index 959dc28..73bd196 100644 --- a/src/lj_debug.c +++ b/src/lj_debug.c @@ -427,12 +427,16 @@ int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, int ext) TValue *frame = NULL; TValue *nextframe = NULL; GCfunc *fn; - if (*what == '>') { - TValue *func = L->top - 1; - api_check(L, tvisfunc(func)); - fn = funcV(func); - L->top--; - what++; + if (*what == '>') { /* we have to have an extra arg on stack */ + if (lua_gettop(L) > 2) { + TValue *func = L->top - 1; + api_check(L, tvisfunc(func)); + fn = funcV(func); + L->top--; + what++; + } else { /* need better error to display? */ + return 0; + } } else { uint32_t offset = (uint32_t)ar->i_ci & 0xffff; uint32_t size = (uint32_t)ar->i_ci >> 16; -- 2.17.1