From: Andrey Hristov Date: Wed, 30 Nov 2005 15:26:41 +0000 (+0000) Subject: fix more leaks. handle better unknown type (4.1.x connected to 5.0.x X-Git-Tag: php-5.1.2RC1~294 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a8c0463961d148f2890e06d61647d25493c88945;p=php fix more leaks. handle better unknown type (4.1.x connected to 5.0.x incompatibility) --- diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 9ade72bb8c..7e4ef4d027 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -345,6 +345,9 @@ PHP_FUNCTION(mysqli_stmt_bind_result) bind[ofs].buffer_length = stmt->result.buf[ofs].buflen; bind[ofs].length = &stmt->result.buf[ofs].buflen; break; + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Server returned unknown type %ld. Probably your client library is incompatible with the server version you use!", col_type); + break; } } @@ -354,9 +357,13 @@ PHP_FUNCTION(mysqli_stmt_bind_result) if (rc) { efree(bind); efree(args); - /* dont close the statement or subsequent usage (for example ->execute()) will lead to crash */ - efree(stmt->result.buf); - efree(stmt->result.is_null); + /* dont close the statement or subsequent usage (for example ->execute()) will lead to crash */ + for (i=0; i < var_cnt ; i++) { + if (stmt->result.buf[i].val) + efree(stmt->result.buf[i].val); + } + efree(stmt->result.buf); + efree(stmt->result.is_null); RETURN_FALSE; } diff --git a/ext/mysqli/tests/013.phpt b/ext/mysqli/tests/013.phpt index ff435f94db..983ceba14c 100644 --- a/ext/mysqli/tests/013.phpt +++ b/ext/mysqli/tests/013.phpt @@ -25,7 +25,7 @@ mysqli fetch mixed / mysql_query $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result"); $c = array(0,0,0,0,0,0,0,0); - mysqli_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]); + $b_res= mysqli_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]); mysqli_execute($stmt); mysqli_fetch($stmt); mysqli_fetch($stmt); @@ -38,10 +38,15 @@ mysqli fetch mixed / mysql_query $test = ""; for ($i=0; $i < count($c); $i++) $test .= ($c[0] == $d[0]) ? "1" : "0"; - - var_dump($test); + if ($test == "11111111") + echo "ok"; + else if ($b_res == FALSE && mysqli_get_client_version() > 40100 && mysqli_get_client_version() < 50000 && + mysqli_get_server_version($link) > 50000) + echo "error (4.1 library with 5.x server)"; + else + echo "error"; mysqli_close($link); ?> ---EXPECT-- -string(8) "11111111" +--EXPECTF-- +ok