diff --git a/include/mariadb_stmt.h b/include/mariadb_stmt.h index 1947c83d..347eaf2c 100644 --- a/include/mariadb_stmt.h +++ b/include/mariadb_stmt.h @@ -38,7 +38,9 @@ { \ (a)->last_errno= (b);\ strncpy((a)->sqlstate, (c), SQLSTATE_LENGTH);\ + (a)->sqlstate[SQLSTATE_LENGTH]= 0;\ strncpy((a)->last_error, (d) ? (d) : ER((b)), MYSQL_ERRMSG_SIZE - 1);\ + (a)->last_error[MYSQL_ERRMSG_SIZE - 1]= 0;\ } #define CLEAR_CLIENT_STMT_ERROR(a) \ diff --git a/include/mysql.h b/include/mysql.h index ef41db5f..843489e1 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -125,7 +125,9 @@ extern unsigned int mariadb_deinitialize_ssl; { \ (a)->net.last_errno= (b);\ strncpy((a)->net.sqlstate, (c), SQLSTATE_LENGTH);\ + (a)->net.sqlstate[SQLSTATE_LENGTH]= 0;\ strncpy((a)->net.last_error, (d) ? (d) : ER((b)), MYSQL_ERRMSG_SIZE - 1);\ + (a)->net.last_error[MYSQL_ERRMSG_SIZE - 1]= 0;\ } /* For mysql_async.c */