Commit 22e9aa1c authored by Igor Solodovnikov's avatar Igor Solodovnikov

Bug #18053212 MYSQL_GET_SERVER_VERSION() CALL WITHOUT A VALID CONNECTION RESULTS IN SEG FAULT

When there is no connection mysql_get_server_version() will return 0
and report CR_COMMANDS_OUT_OF_SYNC error.
parent 1b74f2e3
......@@ -4230,17 +4230,27 @@ const char * STDCALL mysql_error(MYSQL *mysql)
RETURN
Signed number > 323000
Zero if there is no connection
*/
ulong STDCALL
mysql_get_server_version(MYSQL *mysql)
{
uint major, minor, version;
char *pos= mysql->server_version, *end_pos;
major= (uint) strtoul(pos, &end_pos, 10); pos=end_pos+1;
minor= (uint) strtoul(pos, &end_pos, 10); pos=end_pos+1;
version= (uint) strtoul(pos, &end_pos, 10);
return (ulong) major*10000L+(ulong) (minor*100+version);
ulong major= 0, minor= 0, version= 0;
if (mysql->server_version)
{
char *pos= mysql->server_version, *end_pos;
major= strtoul(pos, &end_pos, 10); pos=end_pos+1;
minor= strtoul(pos, &end_pos, 10); pos=end_pos+1;
version= strtoul(pos, &end_pos, 10);
}
else
{
set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
}
return major*10000 + minor*100 + version;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment