summaryrefslogtreecommitdiff
path: root/ext/mysqli
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2005-11-30 15:26:41 +0000
committerAndrey Hristov <andrey@php.net>2005-11-30 15:26:41 +0000
commita8c0463961d148f2890e06d61647d25493c88945 (patch)
tree3d784eb5c5594da2e59c727ad1dbc9868f5b66db /ext/mysqli
parent5b6cc7d96cb2df5ff8825fe622eb6f38fd663e76 (diff)
downloadphp-git-a8c0463961d148f2890e06d61647d25493c88945.tar.gz
fix more leaks. handle better unknown type (4.1.x connected to 5.0.x
incompatibility)
Diffstat (limited to 'ext/mysqli')
-rw-r--r--ext/mysqli/mysqli_api.c13
-rw-r--r--ext/mysqli/tests/013.phpt15
2 files changed, 20 insertions, 8 deletions
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