From dd4996cd5653213160d9b671c074b10cacd6df22 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Sun, 2 Aug 2015 19:42:42 +0200 Subject: [PATCH] delete v8::Extension instance on shutdown --- v8js_class.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/v8js_class.cc b/v8js_class.cc index 924de4d..a54c8a7 100644 --- a/v8js_class.cc +++ b/v8js_class.cc @@ -62,6 +62,7 @@ struct v8js_jsext { int deps_count; char *name; char *source; + v8::Extension *extension; }; /* }}} */ @@ -241,6 +242,7 @@ static void v8js_jsext_dtor(v8js_jsext *jsext) /* {{{ */ if (jsext->deps) { v8js_free_ext_strarr(jsext->deps, jsext->deps_count); } + delete jsext->extension; free(jsext->name); free(jsext->source); } @@ -822,15 +824,16 @@ static int v8js_register_extension(char *name, uint name_len, char *source, uint zend_hash_copy(jsext->deps_ht, Z_ARRVAL_P(deps_arr), (copy_ctor_func_t) v8js_persistent_zval_ctor, NULL, sizeof(zval *)); } + jsext->extension = new v8::Extension(jsext->name, jsext->source, jsext->deps_count, jsext->deps); + if (zend_hash_add(V8JSG(extensions), name, name_len + 1, jsext, sizeof(v8js_jsext), NULL) == FAILURE) { v8js_jsext_dtor(jsext); free(jsext); return FAILURE; } - v8::Extension *extension = new v8::Extension(jsext->name, jsext->source, jsext->deps_count, jsext->deps); - extension->set_auto_enable(auto_enable ? true : false); - v8::RegisterExtension(extension); + jsext->extension->set_auto_enable(auto_enable ? true : false); + v8::RegisterExtension(jsext->extension); free(jsext);