mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
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.
This commit is contained in:
parent
58b9807826
commit
9688cbc250
1 changed files with 16 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue