]> git.kaiwu.me - njs.git/commitdiff
Fixed njs_object_hash_create() for 0 elements.
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 23 Mar 2018 11:03:09 +0000 (14:03 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Fri, 23 Mar 2018 11:03:09 +0000 (14:03 +0300)
njs/njs_object.c

index 614ada8e4971ccfeadc5a2fd18472ac24c500b2a..8983bc7b4c1994e28392ca2adfa68ab05434788c 100644 (file)
@@ -111,7 +111,7 @@ njs_object_hash_create(njs_vm_t *vm, nxt_lvlhsh_t *hash,
     lhq.proto = &njs_object_hash_proto;
     lhq.pool = vm->mem_cache_pool;
 
-    do {
+    while (n != 0) {
         njs_string_get(&prop->name, &lhq.key);
         lhq.key_hash = nxt_djb_hash(lhq.key.start, lhq.key.length);
         lhq.value = (void *) prop;
@@ -123,7 +123,7 @@ njs_object_hash_create(njs_vm_t *vm, nxt_lvlhsh_t *hash,
 
         prop++;
         n--;
-    } while (n != 0);
+    }
 
     return NXT_OK;
 }