cvs: php4(php_4_0_4) /ext/standard var.c

From: Date: Mon, 11 Dec 2000 15:21:37 +0000
Subject: cvs: php4(php_4_0_4) /ext/standard var.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-3077@lists.php.net to get a copy of this message
stas Mon Dec 11 07:21:37 2000 EDT Branch: php_4_0_4 Modified files: /php4/ext/standard var.c Log: Fix serializer bug (merge with HEAD) Index: php4/ext/standard/var.c diff -u php4/ext/standard/var.c:1.80.2.1 php4/ext/standard/var.c:1.80.2.2 --- php4/ext/standard/var.c:1.80.2.1 Mon Dec 11 04:55:17 2000 +++ php4/ext/standard/var.c Mon Dec 11 07:21:37 2000 @@ -16,9 +16,9 @@ | Thies C. Arntzen <thies@thieso.net> | | Sascha Schumann <sascha@schumann.cx> | +----------------------------------------------------------------------+ - */ +*/ -/* $Id: var.c,v 1.80.2.1 2000/12/11 12:55:17 thies Exp $ */ +/* $Id: var.c,v 1.80.2.2 2000/12/11 15:21:37 stas Exp $ */ /* {{{ includes @@ -158,14 +158,21 @@ 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; } @@ -262,7 +269,7 @@ php_error(E_NOTICE, "__sleep should return an array only containing the names of instance-variables to serialize."); continue; } - + if (zend_hash_find((*struc)->value.obj.properties,(*name)->value.str.val,(*name)->value.str.len+1,(void*)&d) == SUCCESS) { php_var_serialize(buf, name, NULL); php_var_serialize(buf,d,var_hash);

« previous php.cvs (#3077) next »