diff options
-rw-r--r-- | src/nxt_var.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/nxt_var.c b/src/nxt_var.c index 729de788..e45c4f14 100644 --- a/src/nxt_var.c +++ b/src/nxt_var.c @@ -132,18 +132,13 @@ nxt_var_ref_get(nxt_tstr_state_t *state, nxt_str_t *name) ref->index = state->var_refs->nelts - 1; - ref->name = nxt_str_dup(state->pool, NULL, name); - if (nxt_slow_path(ref->name == NULL)) { - return NULL; - } - decl = nxt_var_hash_find(name); if (decl != NULL) { ref->handler = decl->handler; ref->cacheable = decl->cacheable; - return ref; + goto done; } ret = nxt_http_unknown_var_ref(state, ref, name); @@ -151,6 +146,13 @@ nxt_var_ref_get(nxt_tstr_state_t *state, nxt_str_t *name) return NULL; } +done: + + ref->name = nxt_str_dup(state->pool, NULL, name); + if (nxt_slow_path(ref->name == NULL)) { + return NULL; + } + return ref; } |