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-12446:

When no default configuration is present, C/C crashed due to double free
in ma_default.c
This commit is contained in:
Georg Richter
2017-03-20 07:29:51 +01:00
parent a1315d2a2d
commit 6bec9204f0
2 changed files with 22 additions and 2 deletions

View File

@@ -1069,7 +1069,28 @@ static int test_reset(MYSQL *mysql)
return OK;
}
static int test_mdev12446(MYSQL *my __attribute__((unused)))
{
/*
if specified file didn't exist, valgrind reported a leak,
if no file was specified and no default file is installed,
C/C crashed due to double free.
*/
MYSQL *mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "file.notfound");
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0), mysql_error(mysql));
mysql_close(mysql);
mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "notfound");
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0), mysql_error(mysql));
mysql_close(mysql);
return OK;
}
struct my_tests_st my_tests[] = {
{"test_mdev12446", test_mdev12446, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_reset", test_reset, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_unix_socket_close", test_unix_socket_close, TEST_CONNECTION_NONE, 0, NULL, NULL},
{"test_sess_track_db", test_sess_track_db, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},