com php-src: We can't dereference dbh if it is NULL: ext/pdo_mysql/pdo_mysql.c
| From: | Johannes Schlüter | Date: | Sun, 23 Feb 2014 13:18:24 +0000 |
| Subject: | com php-src: We can't dereference dbh if it is NULL: ext/pdo_mysql/pdo_mysql.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76189@lists.php.net to get a copy of this message | ||
Commit: 756ee95605ab0677bfd20e0d1f0ba1053b2075d7
Author: Johannes Schlüter <johannes@php.net> Sun, 23 Feb 2014 14:18:24 +0100
Parents: ce1fd72776292dd81c0e39d470631d9a3f62ddb6
Branches: PHP-5.4 PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=756ee95605ab0677bfd20e0d1f0ba1053b2075d7
Log:
We can't dereference dbh if it is NULL
Changed paths:
M ext/pdo_mysql/pdo_mysql.c
Diff:
diff --git a/ext/pdo_mysql/pdo_mysql.c b/ext/pdo_mysql/pdo_mysql.c
index 95f2840..697e7c0 100644
--- a/ext/pdo_mysql/pdo_mysql.c
+++ b/ext/pdo_mysql/pdo_mysql.c
@@ -64,7 +64,12 @@ static MYSQLND * pdo_mysql_convert_zv_to_mysqlnd(zval * zv TSRMLS_DC)
if (Z_TYPE_P(zv) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zv), php_pdo_get_dbh_ce()
TSRMLS_CC)) {
pdo_dbh_t * dbh = zend_object_store_get_object(zv TSRMLS_CC);
- if (!dbh || dbh->driver != &pdo_mysql_driver) {
+ if (!dbh) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to retrieve handle from object
store");
+ return NULL;
+ }
+
+ if (dbh->driver != &pdo_mysql_driver) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Provided PDO instance is not using MySQL but
%s", dbh->driver->driver_name);
return NULL;
}