cvs: php4 /ext/standard var.c
| From: | Stanislav Malyshev | Date: | Mon, 11 Dec 2000 14:29:26 +0000 |
| Subject: | cvs: php4 /ext/standard var.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-3070@lists.php.net to get a copy of this message | ||
stas Mon Dec 11 06:29:26 2000 EDT
Modified files:
/php4/ext/standard var.c
Log:
Fix serializer bug that prevented serializer from working on any
variable that had non-reference copies of the same zval
Index: php4/ext/standard/var.c
diff -u php4/ext/standard/var.c:1.81 php4/ext/standard/var.c:1.82
--- php4/ext/standard/var.c:1.81 Mon Dec 11 04:52:52 2000
+++ php4/ext/standard/var.c Mon Dec 11 06:29:25 2000
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: var.c,v 1.81 2000/12/11 12:52:52 thies Exp $ */
+/* $Id: var.c,v 1.82 2000/12/11 14:29:25 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;
}