]> git.kaiwu.me - nginx.git/commitdiff
fix posix_memalign() error handling
authorIgor Sysoev <igor@sysoev.ru>
Sun, 15 Nov 2009 08:56:40 +0000 (08:56 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Sun, 15 Nov 2009 08:56:40 +0000 (08:56 +0000)
src/os/unix/ngx_alloc.c

index c38d7d27e04fe2993f88bb70b693f034706aeb38..25311743428a50b5fc5cc6112af1c40f03842ddf 100644 (file)
@@ -51,11 +51,15 @@ void *
 ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
 {
     void  *p;
+    int    err;
 
-    if (posix_memalign(&p, alignment, size) == -1) {
-        ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
+    err = posix_memalign(&p, alignment, size);
+
+    if (err) {
+        ngx_log_error(NGX_LOG_EMERG, log, err,
                       "posix_memalign() %uz bytes aligned to %uz failed",
                       size, alignment);
+        p = NULL;
     }
 
     ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0,