Klaus Demo nginx / 9258872
store name pointer in variable allocated on stack as resolver ctx may be already deallocated at this point Igor Sysoev 13 years ago
1 changed file(s) with 7 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
577577 ngx_int_t
578578 ngx_resolve_addr(ngx_resolver_ctx_t *ctx)
579579 {
580 u_char *name;
580581 ngx_resolver_t *r;
581582 ngx_resolver_node_t *rn;
582583
600601
601602 ngx_queue_insert_head(&r->addr_expire_queue, &rn->queue);
602603
603 ctx->name.len = rn->nlen;
604 ctx->name.data = ngx_resolver_dup(r, rn->name, rn->nlen);
605 if (ctx->name.data == NULL) {
604 name = ngx_resolver_dup(r, rn->name, rn->nlen);
605 if (name == NULL) {
606606 goto failed;
607607 }
608608
609 ctx->name.len = rn->nlen;
610 ctx->name.data = name;
611
609612 /* unlock addr mutex */
610613
611614 ctx->state = NGX_OK;
612615
613616 ctx->handler(ctx);
614617
615 ngx_resolver_free(r, ctx->name.data);
618 ngx_resolver_free(r, name);
616619
617620 return NGX_OK;
618621 }