com php-src: Fixed reference counting: ext/dba/dba.c ext/dba/tests/dba015.phpt
| From: | Dmitry Stogov | Date: | Wed, 08 Apr 2015 12:47:31 +0000 |
| Subject: | com php-src: Fixed reference counting: ext/dba/dba.c ext/dba/tests/dba015.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-86125@lists.php.net to get a copy of this message | ||
Commit: fa348dcdfa9460a82a7fc1175126e687ae2edc65
Author: Dmitry Stogov <dmitry@zend.com> Wed, 8 Apr 2015 15:47:31 +0300
Parents: 4d9a1883aa764e502990488d2e8b9c978be6fbd2
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fa348dcdfa9460a82a7fc1175126e687ae2edc65
Log:
Fixed reference counting
Changed paths:
M ext/dba/dba.c
M ext/dba/tests/dba015.phpt
Diff:
diff --git a/ext/dba/dba.c b/ext/dba/dba.c
index 70e2f21..66066de 100644
--- a/ext/dba/dba.c
+++ b/ext/dba/dba.c
@@ -452,7 +452,15 @@ static void dba_close_rsrc(zend_resource *rsrc)
/* {{{ dba_close_pe_rsrc_deleter */
int dba_close_pe_rsrc_deleter(zval *el, void *pDba)
{
- return ((zend_resource *)Z_PTR_P(el))->ptr == pDba ? ZEND_HASH_APPLY_REMOVE:
ZEND_HASH_APPLY_KEEP;
+ if (Z_RES_P(el)->ptr == pDba) {
+ if (Z_DELREF_P(el) == 0) {
+ return ZEND_HASH_APPLY_REMOVE;
+ } else {
+ return ZEND_HASH_APPLY_KEEP | ZEND_HASH_APPLY_STOP;
+ }
+ } else {
+ return ZEND_HASH_APPLY_KEEP;
+ }
}
/* }}} */
@@ -675,7 +683,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
info = (dba_info *)le->ptr;
GC_REFCOUNT(le)++;
- RETURN_RES(le);
+ RETURN_RES(zend_register_resource(info, le_pdb));
return;
}
}
@@ -933,11 +941,10 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
info->argv = NULL;
if (persistent) {
- zend_resource new_le;
+ zval new_le;
- new_le.type = le_pdb;
- new_le.ptr = info;
- if (zend_hash_str_update_mem(&EG(persistent_list), key, keylen, &new_le,
sizeof(zend_resource)) == NULL) {
+ ZVAL_NEW_PERSISTENT_RES(&new_le, -1, info, le_pdb);
+ if (zend_hash_str_update(&EG(persistent_list), key, keylen, &new_le) == NULL) {
dba_close(info);
php_error_docref2(NULL, Z_STRVAL(args[0]), Z_STRVAL(args[1]), E_WARNING, "Could not
register persistent resource");
FREENOW;
diff --git a/ext/dba/tests/dba015.phpt b/ext/dba/tests/dba015.phpt
index 9f560c5..dbb683d 100644
--- a/ext/dba/tests/dba015.phpt
+++ b/ext/dba/tests/dba015.phpt
@@ -53,8 +53,6 @@ echo dba_fetch("key2", $db_file1), "\n";
<?php
require(dirname(__FILE__) .'/clean.inc');
?>
---XFAIL--
-Test 6 crashes in flatfile_findkey with dba pointer of NULL, bug http://bugs.php.net/bug.php?id=51278
--EXPECTF--
database handler: flatfile
Test 1