Skip to content

Commit efad52d

Browse files
TysonAndreTyson Andre
authored and
Tyson Andre
committed
Use an non-interned zend_string for registerExtension on ZTS
(There are no interned strings in ZTS, see the definition of zend_new_interned_string_int) On NTS, strings must be non-interned in order to last until module shutdown. interned strings are cleaned up before module shutdown.
1 parent 3e862b1 commit efad52d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

v8js_class.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ static void v8js_jsext_free_storage(v8js_jsext *jsext) /* {{{ */
270270
v8js_free_ext_strarr(jsext->deps, jsext->deps_count);
271271
}
272272
delete jsext->extension;
273+
// Free the persisted non-interned strings we allocated.
273274
zend_string_release(jsext->name);
274275
zend_string_release(jsext->source);
275276

@@ -959,8 +960,10 @@ static int v8js_register_extension(zend_string *name, zend_string *source, zval
959960
}
960961

961962
jsext->auto_enable = auto_enable;
962-
jsext->name = zend_string_dup(name, 1);
963-
jsext->source = zend_string_dup(source, 1);
963+
// Allocate a persistent string which will survive until module shutdown on both ZTS(Persistent) and NTS(Not interned, those would be cleaned up)
964+
// (zend_string_dup would return the original interned string, if interned, so we don't use that)
965+
jsext->name = zend_string_init(ZSTR_VAL(name), ZSTR_LEN(name), 1);
966+
jsext->source = zend_string_init(ZSTR_VAL(source), ZSTR_LEN(source), 1);
964967

965968
if (jsext->deps) {
966969
jsext->deps_ht = (HashTable *) malloc(sizeof(HashTable));

0 commit comments

Comments
 (0)