[Tarantool-patches] [PATCH] cppcheck: src/lua/fiber.c null pointer dereference
Sergey Kaplun
skaplun at tarantool.org
Tue Sep 22 08:07:44 MSK 2020
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
More information about the Tarantool-patches
mailing list