# HG changeset patch # User Maxim Dounin # Date 1364579460 0 # Node ID f1521859b8c268b5f817ebc7c3f51610ed56b9da # Parent d6980725e25c3b2c146ab6a8ededadd9e8cf2e0f Merge of r5117, r5123: allocation errors handing during upgrade. *) Core: guard against failed allocation during binary upgrade. Patch by Piotr Sikora. *) Core: fixed resource leak if binary upgrade fails due to no memory. Found by Coverity (CID 992320). diff --git a/src/core/nginx.c b/src/core/nginx.c --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -594,6 +594,10 @@ ngx_exec_new_binary(ngx_cycle_t *cycle, var = ngx_alloc(sizeof(NGINX_VAR) + cycle->listening.nelts * (NGX_INT32_LEN + 1) + 2, cycle->log); + if (var == NULL) { + ngx_free(env); + return NGX_INVALID_PID; + } p = ngx_cpymem(var, NGINX_VAR "=", sizeof(NGINX_VAR));