Skip to content

Commit

Permalink
Fixed bug #75502
Browse files Browse the repository at this point in the history
The string keys were not duplicated into persistent memory in this
case.
  • Loading branch information
nikic committed Jan 1, 2018
1 parent 2fd0b99 commit d534d59
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ PHP NEWS
- SOAP:
. Fixed bug #70469 (SoapClient generates E_ERROR even if exceptions=1 is
used). (Anton Artamonov)
. Fixed bug #75502 (Segmentation fault in zend_string_release). (Nikita)

- SPL:
. Fixed bug #75717 (RecursiveArrayIterator does not traverse arrays by
Expand Down
14 changes: 7 additions & 7 deletions ext/soap/php_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2397,12 +2397,6 @@ static void make_persistent_restriction_char_int(sdlRestrictionCharPtr *rest)
}


static void make_persistent_restriction_char(zval *zv)
{
make_persistent_restriction_char_int((sdlRestrictionCharPtr*)&Z_PTR_P(zv));
}


static void make_persistent_sdl_type_ref(sdlTypePtr *type, HashTable *ptr_map, HashTable *bp_types)
{
sdlTypePtr tmp;
Expand Down Expand Up @@ -2764,9 +2758,15 @@ static sdlTypePtr make_persistent_sdl_type(sdlTypePtr type, HashTable *ptr_map,
}

if (type->restrictions->enumeration) {
sdlRestrictionCharPtr tmp, penum;
ptype->restrictions->enumeration = malloc(sizeof(HashTable));
zend_hash_init(ptype->restrictions->enumeration, zend_hash_num_elements(type->restrictions->enumeration), NULL, delete_restriction_var_char_persistent, 1);
zend_hash_copy(ptype->restrictions->enumeration, type->restrictions->enumeration, make_persistent_restriction_char);
ZEND_HASH_FOREACH_STR_KEY_PTR(type->restrictions->enumeration, key, tmp) {
penum = tmp;
make_persistent_restriction_char_int(&penum);
/* We have to duplicate key emalloc->malloc */
zend_hash_str_add_ptr(ptype->restrictions->enumeration, ZSTR_VAL(key), ZSTR_LEN(key), penum);
} ZEND_HASH_FOREACH_END();
}
}

Expand Down
16 changes: 16 additions & 0 deletions ext/soap/tests/bugs/bug75502.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Bug #75502 (Segmentation fault in zend_string_release)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--INI--
soap.wsdl_cache_enabled=1
soap.wsdl_cache=2
--FILE--
<?php
/* The important part is that restriction>enumeration is used together with mem cache.
* Reuse a WSDL file contains this. */
$client = new SoapClient(dirname(__FILE__)."/bug29236.wsdl");
?>
===DONE===
--EXPECT--
===DONE===

0 comments on commit d534d59

Please sign in to comment.