[njs] Freeing code buffer after is was reallocated.

Dmitry Volyntsev xeioex at nginx.com
Fri Dec 7 15:56:23 UTC 2018


details:   https://hg.nginx.org/njs/rev/bc7a47f35645
branches:  
changeset: 688:bc7a47f35645
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Fri Dec 07 18:33:52 2018 +0300
description:
Freeing code buffer after is was reallocated.

Thanks to ??? (Hong Zhi Dao).

diffstat:

 njs/njs_generator.c |  4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diffs (21 lines):

diff -r 2a13aff6aa1f -r bc7a47f35645 njs/njs_generator.c
--- a/njs/njs_generator.c	Fri Dec 07 17:15:21 2018 +0300
+++ b/njs/njs_generator.c	Fri Dec 07 18:33:52 2018 +0300
@@ -452,6 +452,8 @@ njs_generate_reserve(njs_vm_t *vm, njs_g
     size = generator->code_end - generator->code_start;
     memcpy(p, generator->code_start, size);
 
+    nxt_mem_cache_free(vm->mem_cache_pool, generator->code_start);
+
     generator->code_start = p;
     generator->code_end = p + size;
 
@@ -2223,6 +2225,8 @@ njs_generate_function_scope(njs_vm_t *vm
         lambda->start = generator->code_start;
     }
 
+    nxt_mem_cache_free(vm->mem_cache_pool, generator);
+
     return ret;
 }
 


More information about the nginx-devel mailing list