Skip to content

Commit af713c4

Browse files
kyprizelchewi
authored andcommitted
Best practices: Checking if variables are null before use it
1 parent f8af92f commit af713c4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

nginx/modsecurity/ngx_http_modsecurity.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ ngx_pstrdup0(ngx_pool_t *pool, ngx_str_t *src)
217217
{
218218
u_char *dst;
219219

220+
if (src == NULL) {
221+
return NULL;
222+
}
223+
220224
dst = ngx_pnalloc(pool, src->len + 1);
221225
if (dst == NULL) {
222226
return NULL;
@@ -522,6 +526,10 @@ static int ngx_http_modsecurity_save_headers_in_visitor(void *data,
522526
ngx_http_header_t *hh;
523527
ngx_http_core_main_conf_t *cmcf;
524528

529+
if (r == NULL) {
530+
return 0;
531+
}
532+
525533
h = ngx_list_push(&r->headers_in.headers);
526534
if (h == NULL) {
527535
return 0;

0 commit comments

Comments
 (0)