From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (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 793C6469719 for ; Tue, 22 Sep 2020 08:08:05 +0300 (MSK) Date: Tue, 22 Sep 2020 08:07:44 +0300 From: Sergey Kaplun Message-ID: <20200922050744.GB9277@root> References: <20200921174837.30681-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200921174837.30681-1-skaplun@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH] cppcheck: src/lua/fiber.c null pointer dereference List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Turenko , Leonid Vasiliev Cc: tarantool-patches@dev.tarantool.org On 21.09.20, Sergey Kaplun wrote: > Found and fixed possible null pointer dereference with cppcheck: > > [src/lua/fiber.c:245] -> [src/lua/fiber.c:217]: (warning) Either the condition 'if(func)' is redundant or there is possible null pointer dereference: func. > --- > > Branch: https://github.com/tarantool/tarantool/tree/skaplun/cppcheck-lua-fiber-possible-null-pointer-dereference > > src/lua/fiber.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/lua/fiber.c b/src/lua/fiber.c > index 45bc03787..bb6212b24 100644 > --- a/src/lua/fiber.c > +++ b/src/lua/fiber.c > @@ -214,7 +214,7 @@ fiber_backtrace_cb(int frameno, void *frameret, const char *func, size_t offset, > { > struct lua_fiber_tb_ctx *tb_ctx = (struct lua_fiber_tb_ctx *)cb_ctx; > struct lua_State *L = tb_ctx->L; > - if (strstr(func, "lj_BC_FUNCC") == func) { > + if (func && strstr(func, "lj_BC_FUNCC") == func) { > /* We are in the LUA vm. */ > lua_Debug ar; > while (tb_ctx->R && lua_getstack(tb_ctx->R, tb_ctx->lua_frame, &ar) > 0) { > -- > 2.28.0 > Since we don't have 'cppcheck' subsystem, I've changed it to 'fiber'. I've updated commit message to: ``` fiber: src/lua/fiber.c null pointer dereference Found and fixed possible null pointer dereference with cppcheck: [src/lua/fiber.c:245] -> [src/lua/fiber.c:217]: (warning) Either the condition 'if(func)' is redundant or there is possible null pointer dereference: func. ``` and pushed it to the branch. -- Best regards, Sergey Kaplun