mirror of
https://github.com/php/php-src.git
synced 2025-08-17 22:48:57 +02:00
Fix serializer bug that prevented serializer from working on any
variable that had non-reference copies of the same zval
This commit is contained in:
parent
e68c902e3b
commit
a1c20a04ff
1 changed files with 10 additions and 3 deletions
|
@ -158,14 +158,21 @@ inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old) {
|
|||
ulong var_no;
|
||||
char id[sizeof(void *)*2+3];
|
||||
|
||||
snprintf(id,sizeof(id)-1,"%p",var);
|
||||
snprintf(id,sizeof(id)-1, "%p", var);
|
||||
id[sizeof(id)-1]='\0';
|
||||
if(var_old && zend_hash_find(var_hash,id,sizeof(void *)*2,var_old) == SUCCESS) {
|
||||
|
||||
if(var_old && zend_hash_find(var_hash, id, sizeof(id), var_old) == SUCCESS) {
|
||||
if(!var->is_ref) {
|
||||
/* we still need to bump up the counter, since non-refs will
|
||||
be counted separately by unserializer */
|
||||
var_no = -1;
|
||||
zend_hash_next_index_insert(var_hash, &var_no, sizeof(var_no), NULL);
|
||||
}
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
var_no = zend_hash_num_elements(var_hash)+1; /* +1 because otherwise hash will think we are trying to store NULL pointer */
|
||||
zend_hash_add(var_hash,id,sizeof(void *)*2,&var_no,sizeof(var_no),NULL);
|
||||
zend_hash_add(var_hash, id, sizeof(id), &var_no, sizeof(var_no), NULL);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue