Skip to content

Commit 421a8da

Browse files
committed
chore: fix possible null pointer dereference found by Coverity.
fix openresty#1941. ** CID 339181: Null pointer dereferences (REVERSE_INULL) /src/ngx_http_lua_timer.c: 326 in ngx_http_lua_ngx_timer_helper() ________________________________________________________________________________________________________ *** CID 339181: Null pointer dereferences (REVERSE_INULL) /src/ngx_http_lua_timer.c: 326 in ngx_http_lua_ngx_timer_helper() 320 321 } else { 322 tctx->client_addr_text.len = 0; 323 tctx->client_addr_text.data = NULL; 324 } 325 >>> CID 339181: Null pointer dereferences (REVERSE_INULL) >>> Null-checking "ctx" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 326 if (ctx && ctx->vm_state) { 327 tctx->vm_state = ctx->vm_state; 328 tctx->vm_state->count++; 329 330 } else { 331 tctx->vm_state = NULL;
1 parent c4a3e34 commit 421a8da

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/ngx_http_lua_timer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ ngx_http_lua_ngx_timer_helper(lua_State *L, int every)
173173
}
174174

175175
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
176+
ngx_http_lua_assert(ctx != NULL);
176177

177178
/*
178179
* Since nginx has been confirmed that all timers have been cleaned up when
@@ -323,7 +324,7 @@ ngx_http_lua_ngx_timer_helper(lua_State *L, int every)
323324
tctx->client_addr_text.data = NULL;
324325
}
325326

326-
if (ctx && ctx->vm_state) {
327+
if (ctx->vm_state) {
327328
tctx->vm_state = ctx->vm_state;
328329
tctx->vm_state->count++;
329330

0 commit comments

Comments
 (0)