[PATCH 1 of 2] Core: simplified error handling in ngx_pstrdup()

Tatsuhiko Kubo cubicdaiya at gmail.com
Sat Aug 2 03:30:47 UTC 2014


# HG changeset patch
# User Tatsuhiko Kubo <cubicdaiya at gmail.com>
# Date 1406949459 -32400
#      Sat Aug 02 12:17:39 2014 +0900
# Node ID 21d53d2ef2cd35967df5f788589e5470d650dad3
# Parent  f87afb46ccd26fccc7ed55ca8a7ef89c6256c3f2
Core: simplified error handling in ngx_pstrdup().

diff -r f87afb46ccd2 -r 21d53d2ef2cd src/core/ngx_string.c
--- a/src/core/ngx_string.c	Fri Aug 01 20:04:14 2014 +0900
+++ b/src/core/ngx_string.c	Sat Aug 02 12:17:39 2014 +0900
@@ -59,12 +59,10 @@ ngx_pstrdup(ngx_pool_t *pool, ngx_str_t 
     u_char  *dst;
 
     dst = ngx_pnalloc(pool, src->len);
-    if (dst == NULL) {
-        return NULL;
+    if (dst) {
+        ngx_memcpy(dst, src->data, src->len);
     }
 
-    ngx_memcpy(dst, src->data, src->len);
-
     return dst;
 }
 



More information about the nginx-devel mailing list