johannes Mon, 19 Oct 2009 21:43:34 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=289775
Log: Merge #289581 (Fixed PDORow and PDOStatement crashes when instantiating throught Reflection (Felipe) Bug: http://bugs.php.net/289581 (error getting bug information) Changed paths: U php/php-src/branches/PHP_5_3/NEWS UU php/php-src/branches/PHP_5_3_1/NEWS U php/php-src/branches/PHP_5_3_1/Zend/zend_objects.c U php/php-src/branches/PHP_5_3_1/ext/pdo/pdo_dbh.c U php/php-src/branches/PHP_5_3_1/ext/pdo/pdo_stmt.c A + php/php-src/branches/PHP_5_3_1/ext/pdo/tests/pdo_036.phpt (from php/php-src/branches/PHP_5_3/ext/pdo/tests/pdo_036.phpt:r289581)
Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2009-10-19 21:16:07 UTC (rev 289774) +++ php/php-src/branches/PHP_5_3/NEWS 2009-10-19 21:43:34 UTC (rev 289775) @@ -8,9 +8,6 @@ - Implemented FR #49253 (added support for libcurl's CERTINFO option). (Linus Nielsen Feltzing <li...@haxx.se>) -- Fixed crash when instantiating PDORow and PDOStatement through Reflection. - (Felipe) - - Fixed bug #49855 (import_request_variables() always returns NULL). (Ilia, sjoerd at php dot net) - Fixed bug #49800 (SimpleXML allow (un)serialize() calls without warning). Modified: php/php-src/branches/PHP_5_3_1/NEWS =================================================================== --- php/php-src/branches/PHP_5_3_1/NEWS 2009-10-19 21:16:07 UTC (rev 289774) +++ php/php-src/branches/PHP_5_3_1/NEWS 2009-10-19 21:43:34 UTC (rev 289775) @@ -12,6 +12,8 @@ - Fixed crash in SQLiteDatabase::ArrayQuery() and SQLiteDatabase::SingleQuery() when calling using Reflection. (Felipe) +- Fixed crash when instantiating PDORow and PDOStatement through Reflection. + (Felipe) - Changed ini file directives [PATH=](on Win32) and [HOST=](on all) to be case insensitive (garretts) - Restored shebang line check to CGI sapi (not checked by scanner anymore). Property changes on: php/php-src/branches/PHP_5_3_1/NEWS ___________________________________________________________________ Modified: svn:mergeinfo - /php/php-src/branches/PHP_5_3/NEWS:288028,288034,288067,288081,288083,288085,288087-288088,288096,288111,288116-288117,288159,288202-288204,288208,288215,288246,288263,288265,288267,288329,288339,288351,288354,288378-288379,288393,288396,288411,288437,288439,288446-288448,288462,288510-288511,288514-288518,288522-288524,288531,288537,288541,288547-288548,288555,288562,288571,288575,288580,288583,288585,288598,288603,288638,288644,288653,288676,288679,288705,288741,288743,288745-288747,288749,288784,288793,288834,288892-288893,288896,288940,288943,288945,288953,288973,289004,289019,289027-289028,289030,289039,289046,289049,289076,289123,289214,289216,289247,289249,289285,289339,289341,289351,289366,289368,289372,289445-289446,289531,289546-289547,289557,289568,289587,289612,289621-289624,289666-289667 /php/php-src/trunk/NEWS:284726 + /php/php-src/branches/PHP_5_3/NEWS:288028,288034,288067,288081,288083,288085,288087-288088,288096,288111,288116-288117,288159,288202-288204,288208,288215,288246,288263,288265,288267,288329,288339,288351,288354,288378-288379,288393,288396,288411,288437,288439,288446-288448,288462,288510-288511,288514-288518,288522-288524,288531,288537,288541,288547-288548,288555,288562,288571,288575,288580,288583,288585,288598,288603,288638,288644,288653,288676,288679,288705,288741,288743,288745-288747,288749,288784,288793,288834,288892-288893,288896,288940,288943,288945,288953,288973,289004,289019,289027-289028,289030,289039,289046,289049,289076,289123,289214,289216,289247,289249,289285,289339,289341,289351,289366,289368,289372,289445-289446,289531,289546-289547,289557,289568,289581,289587,289612,289621-289624,289666-289667 /php/php-src/trunk/NEWS:284726 Modified: php/php-src/branches/PHP_5_3_1/Zend/zend_objects.c =================================================================== --- php/php-src/branches/PHP_5_3_1/Zend/zend_objects.c 2009-10-19 21:16:07 UTC (rev 289774) +++ php/php-src/branches/PHP_5_3_1/Zend/zend_objects.c 2009-10-19 21:43:34 UTC (rev 289775) @@ -49,7 +49,7 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handle handle TSRMLS_DC) { - zend_function *destructor = object->ce->destructor; + zend_function *destructor = object ? object->ce->destructor : NULL; if (destructor) { zval *obj; Modified: php/php-src/branches/PHP_5_3_1/ext/pdo/pdo_dbh.c =================================================================== --- php/php-src/branches/PHP_5_3_1/ext/pdo/pdo_dbh.c 2009-10-19 21:16:07 UTC (rev 289774) +++ php/php-src/branches/PHP_5_3_1/ext/pdo/pdo_dbh.c 2009-10-19 21:43:34 UTC (rev 289775) @@ -110,7 +110,7 @@ char *message = NULL; zval *info = NULL; - if (dbh->error_mode == PDO_ERRMODE_SILENT) { + if (dbh == NULL || dbh->error_mode == PDO_ERRMODE_SILENT) { return; } Modified: php/php-src/branches/PHP_5_3_1/ext/pdo/pdo_stmt.c =================================================================== --- php/php-src/branches/PHP_5_3_1/ext/pdo/pdo_stmt.c 2009-10-19 21:16:07 UTC (rev 289774) +++ php/php-src/branches/PHP_5_3_1/ext/pdo/pdo_stmt.c 2009-10-19 21:43:34 UTC (rev 289775) @@ -2663,27 +2663,29 @@ MAKE_STD_ZVAL(return_value); RETVAL_NULL(); - - if (Z_TYPE_P(member) == IS_LONG) { - if (Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count) { - fetch_value(stmt, return_value, Z_LVAL_P(member), NULL TSRMLS_CC); - } - } else { - convert_to_string(member); - /* TODO: replace this with a hash of available column names to column - * numbers */ - for (colno = 0; colno < stmt->column_count; colno++) { - if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { - fetch_value(stmt, return_value, colno, NULL TSRMLS_CC); - Z_SET_REFCOUNT_P(return_value, 0); - Z_UNSET_ISREF_P(return_value); - return return_value; + + if (stmt) { + if (Z_TYPE_P(member) == IS_LONG) { + if (Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count) { + fetch_value(stmt, return_value, Z_LVAL_P(member), NULL TSRMLS_CC); } + } else { + convert_to_string(member); + /* TODO: replace this with a hash of available column names to column + * numbers */ + for (colno = 0; colno < stmt->column_count; colno++) { + if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { + fetch_value(stmt, return_value, colno, NULL TSRMLS_CC); + Z_SET_REFCOUNT_P(return_value, 0); + Z_UNSET_ISREF_P(return_value); + return return_value; + } + } + if (strcmp(Z_STRVAL_P(member), "queryString") == 0) { + zval_ptr_dtor(&return_value); + return std_object_handlers.read_property(object, member, IS_STRING TSRMLS_CC); + } } - if (strcmp(Z_STRVAL_P(member), "queryString") == 0) { - zval_ptr_dtor(&return_value); - return std_object_handlers.read_property(object, member, IS_STRING TSRMLS_CC); - } } Z_SET_REFCOUNT_P(return_value, 0); @@ -2702,16 +2704,18 @@ pdo_stmt_t * stmt = (pdo_stmt_t *) zend_object_store_get_object(object TSRMLS_CC); int colno = -1; - if (Z_TYPE_P(member) == IS_LONG) { - return Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count; - } else { - convert_to_string(member); + if (stmt) { + if (Z_TYPE_P(member) == IS_LONG) { + return Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count; + } else { + convert_to_string(member); - /* TODO: replace this with a hash of available column names to column - * numbers */ - for (colno = 0; colno < stmt->column_count; colno++) { - if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { - return 1; + /* TODO: replace this with a hash of available column names to column + * numbers */ + for (colno = 0; colno < stmt->column_count; colno++) { + if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { + return 1; + } } } } @@ -2729,6 +2733,10 @@ pdo_stmt_t * stmt = (pdo_stmt_t *) zend_object_store_get_object(object TSRMLS_CC); int i; + if (stmt == NULL) { + return NULL; + } + for (i = 0; i < stmt->column_count; i++) { zval *val; MAKE_STD_ZVAL(val); Copied: php/php-src/branches/PHP_5_3_1/ext/pdo/tests/pdo_036.phpt (from rev 289581, php/php-src/branches/PHP_5_3/ext/pdo/tests/pdo_036.phpt) =================================================================== --- php/php-src/branches/PHP_5_3_1/ext/pdo/tests/pdo_036.phpt (rev 0) +++ php/php-src/branches/PHP_5_3_1/ext/pdo/tests/pdo_036.phpt 2009-10-19 21:43:34 UTC (rev 289775) @@ -0,0 +1,21 @@ +--TEST-- +Testing PDORow and PDOStatement instances with Reflection +--FILE-- +<?php + +$instance = new reflectionclass('pdorow'); +$x = $instance->newInstance(); +var_dump($x); + +$instance = new reflectionclass('pdostatement'); +$x = $instance->newInstance(); +var_dump($x); + +?> +--EXPECTF-- +object(PDORow)#%d (0) { +} +object(PDOStatement)#%d (1) { + [%u|b%"queryString"]=> + NULL +}
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php