You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
Fix for CONC-458:
Fixed crash in mysql_get_timeout and mysql_get_timeout_ms functions, which happened when no asynchronous context was set before.
This commit is contained in:
@@ -1751,7 +1751,10 @@ void ma_invalidate_stmts(MYSQL *mysql, const char *function_name)
|
|||||||
unsigned int STDCALL
|
unsigned int STDCALL
|
||||||
mysql_get_timeout_value(const MYSQL *mysql)
|
mysql_get_timeout_value(const MYSQL *mysql)
|
||||||
{
|
{
|
||||||
unsigned int timeout= mysql->options.extension->async_context->timeout_value;
|
unsigned int timeout= 0;
|
||||||
|
|
||||||
|
if (mysql->options.extension && mysql->options.extension->async_context)
|
||||||
|
timeout= mysql->options.extension->async_context->timeout_value;
|
||||||
/* Avoid overflow. */
|
/* Avoid overflow. */
|
||||||
if (timeout > UINT_MAX - 999)
|
if (timeout > UINT_MAX - 999)
|
||||||
return (timeout - 1)/1000 + 1;
|
return (timeout - 1)/1000 + 1;
|
||||||
@@ -1763,7 +1766,9 @@ mysql_get_timeout_value(const MYSQL *mysql)
|
|||||||
unsigned int STDCALL
|
unsigned int STDCALL
|
||||||
mysql_get_timeout_value_ms(const MYSQL *mysql)
|
mysql_get_timeout_value_ms(const MYSQL *mysql)
|
||||||
{
|
{
|
||||||
|
if (mysql->options.extension && mysql->options.extension->async_context)
|
||||||
return mysql->options.extension->async_context->timeout_value;
|
return mysql->options.extension->async_context->timeout_value;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
@@ -1435,8 +1435,17 @@ static int test_conc457(MYSQL *mysql)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int test_conc458(MYSQL *my __attribute__((unused)))
|
||||||
|
{
|
||||||
|
MYSQL *mysql= mysql_init(NULL);
|
||||||
|
FAIL_IF(mysql_get_timeout_value(mysql) != 0, "expected timeout 0");
|
||||||
|
mysql_close(mysql);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct my_tests_st my_tests[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
|
{"test_conc458", test_conc458, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||||
{"test_conc457", test_conc457, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_conc457", test_conc457, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_conc384", test_conc384, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
{"test_conc384", test_conc384, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
Reference in New Issue
Block a user