Skip to content

Commit d66045f

Browse files
committed
Fixed bug #69485 (Double free on zend_list_dtor).
1 parent a819404 commit d66045f

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
. Update the MIME type list from the one shipped by Apache HTTPD. (Adam)
99

1010
- Core:
11+
. Fixed bug #69485 (Double free on zend_list_dtor). (Laruence)
1112
. Fixed bug #69427 (Segfault on magic method __call of private method in
1213
superclass). (Laruence)
1314
. Improved __call() and __callStatic() magic method handling. Now they are

Zend/zend_list.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,19 @@ ZEND_API int zend_list_free(zend_resource *res)
6565
static void zend_resource_dtor(zend_resource *res)
6666
{
6767
zend_rsrc_list_dtors_entry *ld;
68+
zend_resource r = *res;
6869

69-
ld = zend_hash_index_find_ptr(&list_destructors, res->type);
70+
res->type = -1;
71+
res->ptr = NULL;
72+
73+
ld = zend_hash_index_find_ptr(&list_destructors, r.type);
7074
if (ld) {
7175
if (ld->list_dtor_ex) {
72-
ld->list_dtor_ex(res);
76+
ld->list_dtor_ex(&r);
7377
}
7478
} else {
75-
zend_error(E_WARNING,"Unknown list entry type (%d)", res->type);
79+
zend_error(E_WARNING, "Unknown list entry type (%d)", r.type);
7680
}
77-
res->ptr = NULL;
78-
res->type = -1;
7981
}
8082

8183

@@ -178,8 +180,8 @@ void list_entry_destructor(zval *zv)
178180
{
179181
zend_resource *res = Z_RES_P(zv);
180182

183+
ZVAL_UNDEF(zv);
181184
if (res->type >= 0) {
182-
183185
zend_resource_dtor(res);
184186
}
185187
efree_size(res, sizeof(zend_resource));

ext/curl/interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ void _php_curl_verify_handlers(php_curl *ch, int reporterror) /* {{{ */
283283
curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);
284284
}
285285
}
286-
return ;
286+
return;
287287
}
288288
/* }}} */
289289

ext/curl/tests/bug69485.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #69485 (Double free on zend_list_dtor)
3+
--SKIPIF--
4+
<?php include 'skipif.inc'; ?>
5+
--FILE--
6+
<?php
7+
8+
class O {
9+
public $ch;
10+
public function dummy() {
11+
}
12+
}
13+
14+
$ch = curl_init();
15+
16+
$o = new O;
17+
$o->ch = $ch;
18+
curl_setopt($ch, CURLOPT_WRITEFUNCTION, array($o, "dummy"));
19+
?>
20+
==DONE==
21+
--EXPECT--
22+
==DONE==

0 commit comments

Comments
 (0)