diff options
Diffstat (limited to 'src/core/ngx_hunk.c')
-rw-r--r-- | src/core/ngx_hunk.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/core/ngx_hunk.c b/src/core/ngx_hunk.c index 79a8ad748..1f05dc839 100644 --- a/src/core/ngx_hunk.c +++ b/src/core/ngx_hunk.c @@ -5,13 +5,15 @@ ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size, int before, int after) { - ngx_hunk_t *h = ngx_palloc(pool, sizeof(ngx_hunk_t)); + ngx_hunk_t *h; + + ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL); #if !(HAVE_OFFSET_EQUAL_PTR) h->pos.file = h->last.file = 0; #endif - h->pre_start = ngx_palloc(pool, size + before + after); + ngx_test_null(h->pre_start, ngx_palloc(pool, size + before + after), NULL); h->start = h->pos.mem = h->last.mem = h->pre_start + before; h->end = h->last.mem + size; h->post_end = h->end + after; @@ -25,7 +27,9 @@ ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size, ngx_hunk_t *ngx_create_hunk_before(ngx_pool_t *pool, ngx_hunk_t *hunk, int size) { - ngx_hunk_t *h = ngx_palloc(pool, sizeof(ngx_hunk_t)); + ngx_hunk_t *h; + + ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL); #if !(HAVE_OFFSET_EQUAL_PTR) h->pos.file = h->last.file = 0; @@ -42,8 +46,8 @@ ngx_hunk_t *ngx_create_hunk_before(ngx_pool_t *pool, ngx_hunk_t *hunk, int size) h->file = NULL; } else { - h->pre_start = h->start = h->pos.mem = h->last.mem - = ngx_palloc(pool, size); + ngx_test_null(h->pre_start, ngx_palloc(pool, size), NULL); + h->start = h->pos.mem = h->last.mem = h->pre_start; h->end = h->post_end = h->start + size; h->type = NGX_HUNK_TEMP; @@ -56,7 +60,9 @@ ngx_hunk_t *ngx_create_hunk_before(ngx_pool_t *pool, ngx_hunk_t *hunk, int size) ngx_hunk_t *ngx_create_hunk_after(ngx_pool_t *pool, ngx_hunk_t *hunk, int size) { - ngx_hunk_t *h = ngx_palloc(pool, sizeof(ngx_hunk_t)); + ngx_hunk_t *h; + + ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL); #if !(HAVE_OFFSET_EQUAL_PTR) h->pos.file = h->last.file = 0; @@ -74,8 +80,8 @@ ngx_hunk_t *ngx_create_hunk_after(ngx_pool_t *pool, ngx_hunk_t *hunk, int size) h->file = NULL; } else { - h->pre_start = h->start = h->pos.mem = h->last.mem = - ngx_palloc(pool, size); + ngx_test_null(h->pre_start, ngx_palloc(pool, size), NULL); + h->start = h->pos.mem = h->last.mem = h->pre_start; h->end = h->post_end = h->start + size; h->type = NGX_HUNK_TEMP; |