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:
Stanislav Malyshev 2000-12-11 14:29:25 +00:00
parent e68c902e3b
commit a1c20a04ff

View file

@ -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;
}