- Fixed ext/mysqli to allocate less memory when fetching bound params
of type (MEDIUM|LONG)BLOB/(MEDIUM|LONG)TEXT. (Andrey)
- Fixed memory corruption in ImageTTFText() with 64bit systems. (Andrey)
+- Fixed bug #33090 (mysqli_prepare doesn't return an error). (Georg)
- Fixed bug #33076 (str_ireplace() incorrectly counts result string length
and may cause segfault). (Tony)
- Fixed bug #33059 (crash when moving xml attribute set in dtd). (Ilia)
}
/* }}} */
-/* {{{ proto mysqli_set_local_infile_default(object link)
+/* {{{ proto void mysqli_set_local_infile_default(object link)
unsets user defined handler for load local infile command */
PHP_FUNCTION(mysqli_set_local_infile_default)
{
if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
- if (stmt->stmt->last_errno) {
- /* if we close the statement handle, we have to copy the errors to connection handle */
- mysql->mysql->net.last_errno = stmt->stmt->last_errno;
- strcpy(mysql->mysql->net.last_error, stmt->stmt->last_error);
- strcpy(mysql->mysql->net.sqlstate, stmt->stmt->sqlstate);
- }
+ char last_error[MYSQL_ERRMSG_SIZE];
+ char sqlstate[SQLSTATE_LENGTH+1];
+ unsigned int last_errno;
+
+ /* mysql_stmt_close clears errors, so we have to store them temporarily */
+ last_errno = stmt->stmt->last_errno;
+ memcpy(last_error, stmt->stmt->last_error, MYSQL_ERRMSG_SIZE);
+ memcpy(sqlstate, mysql->mysql->net.sqlstate, SQLSTATE_LENGTH+1);
+
mysql_stmt_close(stmt->stmt);
stmt->stmt = NULL;
+
+ /* restore error messages */
+ mysql->mysql->net.last_errno = last_errno;
+ memcpy(mysql->mysql->net.last_error, last_error, MYSQL_ERRMSG_SIZE);
+ memcpy(mysql->mysql->net.sqlstate, sqlstate, SQLSTATE_LENGTH+1);
}
}
--- /dev/null
+--TEST--
+Bug #33090
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+ include ("connect.inc");
+
+ /*** test mysqli_connect 127.0.0.1 ***/
+ $link = mysqli_connect($host, $user, $passwd);
+ mysqli_select_db($link, "test");
+
+ if (!($link->prepare("this makes no sense"))) {
+ printf("%d\n", $link->errno);
+ printf("%s\n", $link->sqlstate);
+ }
+ $link->close();
+?>
+--EXPECT--
+1064
+42000