From b489d3a69fcea9c8a79cb0cf00a09f8d9fd7d058 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Schl=C3=BCter?= Date: Wed, 18 Feb 2009 16:34:47 +0000 Subject: [PATCH] MFH: Fix #47438 mysql_fetch_field ignores zero offse --- NEWS | 1 + ext/mysql/php_mysql.c | 2 +- ext/mysql/tests/bug47438.phpt | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 ext/mysql/tests/bug47438.phpt diff --git a/NEWS b/NEWS index d29a71cb7e..fb4d0fdfed 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ PHP NEWS ?? ??? 2009, PHP 5.3.0 Beta 2 - Upgraded bundled sqlite to version 3.6.11. (Scott) +- Fixed bug #47438 (mysql_fetch_field ignores zero offset). (Johannes) - Fixed bug #47398 (PDO_Firebird doesn't implements quoter correctly). (Felipe) - Fixed bug #47390 (odbc_fetch_into - BC in php 5.3.0). (Felipe) - Fixed bug #47343 (gc_collect_cycles causes a segfault when called within a diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index b7fd650446..56301d9b15 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -2318,7 +2318,7 @@ PHP_FUNCTION(mysql_fetch_field) ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, &result, -1, "MySQL result", le_result); - if (field) { + if (ZEND_NUM_ARGS() > 1) { if (field<0 || field>=(int)mysql_num_fields(mysql_result)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad field offset"); RETURN_FALSE; diff --git a/ext/mysql/tests/bug47438.phpt b/ext/mysql/tests/bug47438.phpt new file mode 100644 index 0000000000..b646b9b424 --- /dev/null +++ b/ext/mysql/tests/bug47438.phpt @@ -0,0 +1,39 @@ +--TEST-- +Bug #47438 mysql_fetch_field ignores zero offset +--SKIPIF-- + +--FILE-- +name . "\n"; + $i++; +} + +mysql_query("DROP TABLE IF EXISTS test_47438"); + +?> +--EXPECT-- +0.a +1.b +2.c -- 2.50.1