From 207c85d9f7511fb4ad0c158255105a0f5f6cfd82 Mon Sep 17 00:00:00 2001 From: Eldar Zaitov Date: Fri, 13 Jun 2014 23:42:09 +0400 Subject: [PATCH] Best practices: Checking if variables are null before use it --- nginx/modsecurity/ngx_http_modsecurity.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nginx/modsecurity/ngx_http_modsecurity.c b/nginx/modsecurity/ngx_http_modsecurity.c index 9e9b2365..078489e2 100644 --- a/nginx/modsecurity/ngx_http_modsecurity.c +++ b/nginx/modsecurity/ngx_http_modsecurity.c @@ -217,6 +217,10 @@ ngx_pstrdup0(ngx_pool_t *pool, ngx_str_t *src) { u_char *dst; + if (src == NULL) { + return NULL; + } + dst = ngx_pnalloc(pool, src->len + 1); if (dst == NULL) { return NULL; @@ -522,6 +526,10 @@ static int ngx_http_modsecurity_save_headers_in_visitor(void *data, ngx_http_header_t *hh; ngx_http_core_main_conf_t *cmcf; + if (r == NULL) { + return 0; + } + h = ngx_list_push(&r->headers_in.headers); if (h == NULL) { return 0;