From 9408303390b0c4b212a5901541aba6ae2027a910 Mon Sep 17 00:00:00 2001 From: Ulf Wendel Date: Wed, 30 Sep 2009 14:39:33 +0000 Subject: Fixing a leak in mysqlnd when passing invalid fetch modes to mysqlnd. --- ext/mysql/php_mysql.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ext/mysql/php_mysql.c') diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index aaee07bc6a..694640f59c 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -1972,7 +1972,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type, } } - if ((result_type & MYSQL_BOTH) == 0) { + if (result_type & ~MYSQL_BOTH) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH"); result_type = MYSQL_BOTH; } @@ -2149,6 +2149,11 @@ PHP_FUNCTION(mysql_fetch_array) } ZEND_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, -1, "MySQL result", le_result); + if (mode & ~MYSQL_BOTH) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH"); + mode = MYSQL_BOTH; + } + mysqlnd_fetch_into(result, mode, return_value, MYSQLND_MYSQL); #endif } -- cgit v1.2.1