]> git.kaiwu.me - nginx.git/commitdiff
Merge of r4690: conflicting wildcard server names fix.
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 2 Jul 2012 16:59:34 +0000 (16:59 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 2 Jul 2012 16:59:34 +0000 (16:59 +0000)
With previous code wildcard names were added to hash even if conflict
was detected.  This resulted in identical names in hash and segfault
later in ngx_hash_wildcard_init().

src/core/ngx_hash.c

index 7d04f7484f9bb8525d883f6e3f4a9e381d28eda3..b532945027cbaadbbf5bc7097b2a02ba3751dad3 100644 (file)
@@ -924,17 +924,6 @@ wildcard:
     }
 
 
-    hk = ngx_array_push(hwc);
-    if (hk == NULL) {
-        return NGX_ERROR;
-    }
-
-    hk->key.len = last - 1;
-    hk->key.data = p;
-    hk->key_hash = 0;
-    hk->value = value;
-
-
     /* check conflicts in wildcard hash */
 
     name = keys->elts;
@@ -972,5 +961,18 @@ wildcard:
 
     ngx_memcpy(name->data, key->data + skip, name->len);
 
+
+    /* add to wildcard hash */
+
+    hk = ngx_array_push(hwc);
+    if (hk == NULL) {
+        return NGX_ERROR;
+    }
+
+    hk->key.len = last - 1;
+    hk->key.data = p;
+    hk->key_hash = 0;
+    hk->value = value;
+
     return NGX_OK;
 }