Skip to content

Commit 09e367d

Browse files
committed
Merge branch 'PHP-5.4' of git.php.net:php-src into PHP-5.4
2 parents a8cc0b0 + 0f00170 commit 09e367d

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ PHP NEWS
9898
ReflectionMethod::invokeArgs()). (Laruence)
9999

100100
- SPL:
101+
. Fixed bug #61453 (SplObjectStorage does not identify objects correctly).
102+
(Gustavo)
101103
. Fixed bug #61347 (inconsistent isset behavior of Arrayobject). (Laruence)
102104

103105
- Standard:

ext/spl/spl_observer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ static char *spl_object_storage_get_hash(spl_SplObjectStorage *intern, zval *thi
146146

147147
return (char*)&Z_OBJVAL_P(obj);
148148
#else
149-
char *hash = emalloc((hash_len+1)*sizeof(char));
149+
char *hash = emalloc(hash_len + 1);
150150

151151
zend_object_value zvalue;
152152
memset(&zvalue, 0, sizeof(zend_object_value));
153153
zvalue.handle = Z_OBJ_HANDLE_P(obj);
154154
zvalue.handlers = Z_OBJ_HT_P(obj);
155155

156-
strncpy(hash, (char *)&zvalue, hash_len);
156+
memcpy(hash, (char *)&zvalue, hash_len);
157157
hash[hash_len] = 0;
158158

159159
if (hash_len_ptr) {

ext/spl/tests/bug61453.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bug #61453: SplObjectStorage does not identify objects correctly
3+
--FILE--
4+
<?php
5+
$limit = 1000;
6+
$objects = new SplObjectStorage;
7+
for($i = 0; $i < $limit; $i++){
8+
$object = new StdClass;
9+
10+
if(isset($objects[$object])){
11+
die("this should never happen, but did after $i iteration");
12+
}
13+
14+
$objects[$object] = 1;
15+
}
16+
?>
17+
==DONE==
18+
--EXPECT--
19+
==DONE==

0 commit comments

Comments
 (0)