Skip to content

Commit 8625f70

Browse files
authored
Merge pull request #255 from TysonAndre/use-non-zend_string-v2
Use an non-interned zend_string for registerExtension on ZTS
2 parents 98e4399 + efad52d commit 8625f70

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ php:
88
env:
99
- V8VER=5.2
1010
- V8VER=5.1
11+
- V8VER=5.2 VALGRIND=1
1112

1213
before_install: make -f Makefile.travis before_install
13-
install: make -f Makefile.travis install
14+
install:
15+
- if [ "$VALGRIND" = 1 ]; then sudo apt-get install -qq valgrind; export TEST_PHP_ARGS="-m"; fi
16+
- make -f Makefile.travis install
17+
1418
script: make -f Makefile.travis test

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

@@ -955,8 +956,10 @@ static int v8js_register_extension(zend_string *name, zend_string *source, zval
955956
}
956957

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

961964
if (jsext->deps) {
962965
jsext->deps_ht = (HashTable *) malloc(sizeof(HashTable));

0 commit comments

Comments
 (0)