NJS: adding the missing vm destruction.
This commit fixed the njs memory leak happened in the config validation, updating and http requests.
This commit is contained in:
17
src/nxt_js.c
17
src/nxt_js.c
@@ -46,6 +46,7 @@ nxt_js_conf_new(nxt_mp_t *mp)
|
||||
|
||||
jcf->funcs = nxt_array_create(mp, 4, sizeof(nxt_str_t));
|
||||
if (nxt_slow_path(jcf->funcs == NULL)) {
|
||||
njs_vm_destroy(jcf->vm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -53,6 +54,13 @@ nxt_js_conf_new(nxt_mp_t *mp)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nxt_js_conf_release(nxt_js_conf_t *jcf)
|
||||
{
|
||||
njs_vm_destroy(jcf->vm);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nxt_js_set_proto(nxt_js_conf_t *jcf, njs_external_t *proto, njs_uint_t n)
|
||||
{
|
||||
@@ -297,3 +305,12 @@ nxt_js_call(nxt_task_t *task, nxt_js_cache_t *cache, nxt_js_t *js,
|
||||
|
||||
return NXT_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nxt_js_release(nxt_js_cache_t *cache)
|
||||
{
|
||||
if (cache->vm != NULL) {
|
||||
njs_vm_destroy(cache->vm);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user