felipe Fri Feb 13 02:18:04 2009 UTC
Modified files:
/php-src/ext/pdo pdo_dbh.c
Log:
- Fixed bug #43831 ($this gets mangled when extending PDO with persistent
connection)
- Fixed bug #45432 (PDO: persistent connection leak)
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/pdo_dbh.c?r1=1.159&r2=1.160&diff_format=u
Index: php-src/ext/pdo/pdo_dbh.c
diff -u php-src/ext/pdo/pdo_dbh.c:1.159 php-src/ext/pdo/pdo_dbh.c:1.160
--- php-src/ext/pdo/pdo_dbh.c:1.159 Wed Dec 31 11:12:34 2008
+++ php-src/ext/pdo/pdo_dbh.c Fri Feb 13 02:18:04 2009
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_dbh.c,v 1.159 2008/12/31 11:12:34 sebastian Exp $ */
+/* $Id: pdo_dbh.c,v 1.160 2009/02/13 02:18:04 felipe Exp $ */
/* The PDO Database Handle Class */
@@ -328,23 +328,27 @@
memcpy((char *)pdbh->persistent_id, hashkey,
plen+1);
pdbh->persistent_id_len = plen+1;
pdbh->refcount = 1;
+ pdbh->properties = NULL;
}
}
if (pdbh) {
/* let's copy the emalloc bits over from the other
handle */
- pdbh->ce = dbh->ce;
- pdbh->def_stmt_ce = dbh->def_stmt_ce;
- pdbh->def_stmt_ctor_args = dbh->def_stmt_ctor_args;
- pdbh->properties = dbh->properties;
+ if (pdbh->properties) {
+ zend_hash_destroy(dbh->properties);
+ efree(dbh->properties);
+ } else {
+ pdbh->ce = dbh->ce;
+ pdbh->def_stmt_ce = dbh->def_stmt_ce;
+ pdbh->def_stmt_ctor_args =
dbh->def_stmt_ctor_args;
+ pdbh->properties = dbh->properties;
+ }
/* kill the non-persistent thingamy */
efree(dbh);
/* switch over to the persistent one */
dbh = pdbh;
zend_object_store_set_object(object, dbh TSRMLS_CC);
- if (!call_factory) {
- dbh->refcount++;
- }
+ dbh->refcount++;
}
if (hashkey) {
@@ -352,11 +356,13 @@
}
}
- dbh->data_source_len = strlen(colon + 1);
- dbh->data_source = (const char*)pestrdup(colon + 1, is_persistent);
- dbh->username = username ? pestrdup(username, is_persistent) : NULL;
- dbh->password = password ? pestrdup(password, is_persistent) : NULL;
- dbh->default_fetch_type = PDO_FETCH_BOTH;
+ if (call_factory) {
+ dbh->data_source_len = strlen(colon + 1);
+ dbh->data_source = (const char*)pestrdup(colon + 1,
is_persistent);
+ dbh->username = username ? pestrdup(username, is_persistent) :
NULL;
+ dbh->password = password ? pestrdup(password, is_persistent) :
NULL;
+ dbh->default_fetch_type = PDO_FETCH_BOTH;
+ }
dbh->auto_commit = pdo_attr_lval(options, PDO_ATTR_AUTOCOMMIT, 1
TSRMLS_CC);
@@ -1520,11 +1526,10 @@
dbh->properties = NULL;
}
- if (!dbh->is_persistent) {
- dbh_free(dbh TSRMLS_CC);
- } else if (dbh->methods && dbh->methods->persistent_shutdown) {
+ if (dbh->is_persistent && dbh->methods &&
dbh->methods->persistent_shutdown) {
dbh->methods->persistent_shutdown(dbh TSRMLS_CC);
}
+ dbh_free(dbh TSRMLS_CC);
}
zend_object_value pdo_dbh_new(zend_class_entry *ce TSRMLS_DC)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php