1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

Fix for MDEV-21920

when converting (or copying) from string empty string weren't handled
correctly. This was a regression error, introduced by a prior covscan fix.
This commit is contained in:
Georg Richter
2020-03-12 12:06:40 +01:00
parent f9a50468cd
commit 3be5897c33
2 changed files with 36 additions and 1 deletions

View File

@@ -5161,7 +5161,42 @@ static int test_maxparam(MYSQL *mysql)
return OK;
}
static int test_mdev_21920(MYSQL *mysql)
{
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
MYSQL_BIND bind[1];
int rc;
char buffer[128];
rc= mysql_stmt_prepare(stmt, SL("SELECT ''"));
check_stmt_rc(rc, stmt);
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
buffer[0]= 1;
memset(bind, 0, sizeof(MYSQL_BIND));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= buffer;
bind[0].buffer_length= 127;
rc= mysql_stmt_bind_result(stmt, bind);
check_stmt_rc(rc, stmt);
rc= mysql_stmt_fetch(stmt);
check_stmt_rc(rc, stmt);
FAIL_IF(buffer[0] != 0, "Expected empty string");
mysql_stmt_close(stmt);
return OK;
}
struct my_tests_st my_tests[] = {
{"test_mdev_21920", test_mdev_21920, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_maxparam", test_maxparam, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc424", test_conc424, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc344", test_conc344, TEST_CONNECTION_NEW, 0, NULL, NULL},