moriyoshi Sat Jul 3 12:10:29 2004 EDT Modified files: /php-src/ext/standard var.c Log: - Bugfix #28325 (circular reference serialisation). http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.189&r2=1.190&ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.189 php-src/ext/standard/var.c:1.190 --- php-src/ext/standard/var.c:1.189 Thu May 20 17:15:42 2004 +++ php-src/ext/standard/var.c Sat Jul 3 12:10:28 2004 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: var.c,v 1.189 2004/05/20 21:15:42 andrey Exp $ */ +/* $Id: var.c,v 1.190 2004/07/03 16:10:28 moriyoshi Exp $ */ /* {{{ includes @@ -467,10 +467,21 @@ char id[32], *p; register int len; - /* relies on "(long)" being a perfect hash function for data pointers */ - p = smart_str_print_long(id + sizeof(id) - 1, (long) var); - len = id + sizeof(id) - 1 - p; - + /* relies on "(long)" being a perfect hash function for data pointers, + however the actual identity of an object has had to be determined + by its object handle and the class entry since 5.0. */ + if (Z_TYPE_P(var) == IS_OBJECT) { + p = smart_str_print_long(id + sizeof(id) - 1, + (((unsigned long)Z_OBJCE_P(var) << 5) + | ((unsigned long)Z_OBJCE_P(var) >> (sizeof(long) * 8 - 5))) + + (long) Z_OBJ_HANDLE_P(var)); + *(--p) = 'O'; + len = id + sizeof(id) - 1 - p; + } else { + p = smart_str_print_long(id + sizeof(id) - 1, (long) var); + len = id + sizeof(id) - 1 - p; + } + if (var_old && zend_hash_find(var_hash, p, len, var_old) == SUCCESS) { if (!var->is_ref) { /* we still need to bump up the counter, since non-refs will @@ -588,8 +599,8 @@ ulong *var_already; HashTable *myht; - if(var_hash - && php_add_var_hash(var_hash, *struc, (void *) &var_already) == FAILURE) { + if (var_hash + && php_add_var_hash(var_hash, *struc, (void *) &var_already) == FAILURE) { if((*struc)->is_ref) { smart_str_appendl(buf, "R:", 2); smart_str_append_long(buf, *var_already); @@ -703,7 +714,7 @@ } switch (i) { - case HASH_KEY_IS_LONG: + case HASH_KEY_IS_LONG: php_var_serialize_long(buf, index); break; case HASH_KEY_IS_STRING:
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php