[njs] Old array data are freed after array relocation.

Igor Sysoev igor at sysoev.ru
Sat Apr 9 09:22:59 UTC 2016


details:   http://hg.nginx.org/njs/rev/24544f647802
branches:  
changeset: 97:24544f647802
user:      Igor Sysoev <igor at sysoev.ru>
date:      Sat Apr 09 12:21:31 2016 +0300
description:
Old array data are freed after array relocation.

diffstat:

 njs/njs_array.c |  7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r 160e59aaf9bb -r 24544f647802 njs/njs_array.c
--- a/njs/njs_array.c	Sat Apr 09 12:18:47 2016 +0300
+++ b/njs/njs_array.c	Sat Apr 09 12:21:31 2016 +0300
@@ -143,7 +143,7 @@ njs_array_realloc(njs_vm_t *vm, njs_arra
     uint32_t size)
 {
     nxt_uint_t   n;
-    njs_value_t  *value;
+    njs_value_t  *value, *old;
 
     if (size != array->size) {
         if (size < 16) {
@@ -160,8 +160,7 @@ njs_array_realloc(njs_vm_t *vm, njs_arra
         return NXT_ERROR;
     }
 
-    /* GC: old = array->data */
-
+    old = array->data;
     array->data = value;
 
     while (prepend != 0) {
@@ -185,7 +184,7 @@ njs_array_realloc(njs_vm_t *vm, njs_arra
         size--;
     }
 
-    /* GC: free old pointer. */
+    nxt_mem_cache_free(vm->mem_cache_pool, old);
 
     return NXT_OK;
 }



More information about the nginx-devel mailing list