Skip to content

Commit

Permalink
Fixes crash on shutdown when connection is null
Browse files Browse the repository at this point in the history
  • Loading branch information
pondix committed May 18, 2018
1 parent 9c1a794 commit 3819fb2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2922,8 +2922,12 @@ int MySQL_Session::handler() {
case PROCESSING_STMT_PREPARE:
{
char sqlstate[10];
sprintf(sqlstate,"%s",mysql_sqlstate(myconn->mysql));
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,client_myds->pkt_sid+1,mysql_errno(myconn->mysql),sqlstate,(char *)mysql_stmt_error(myconn->query.stmt));
if (myconn->mysql) {
sprintf(sqlstate,"%s",mysql_sqlstate(myconn->mysql));
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,client_myds->pkt_sid+1,mysql_errno(myconn->mysql),sqlstate,(char *)mysql_stmt_error(myconn->query.stmt));
} else {
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,client_myds->pkt_sid+1, 2013, (char *)"" ,(char *)"Lost connection to MySQL server during query");
}
client_myds->pkt_sid++;
if (previous_status.size()) {
// an STMT_PREPARE failed
Expand All @@ -2937,8 +2941,12 @@ int MySQL_Session::handler() {
case PROCESSING_STMT_EXECUTE:
{
char sqlstate[10];
sprintf(sqlstate,"%s",mysql_sqlstate(myconn->mysql));
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,client_myds->pkt_sid+1,mysql_errno(myconn->mysql),sqlstate,(char *)mysql_stmt_error(myconn->query.stmt));
if (myconn->mysql) {
sprintf(sqlstate,"%s",mysql_sqlstate(myconn->mysql));
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,client_myds->pkt_sid+1,mysql_errno(myconn->mysql),sqlstate,(char *)mysql_stmt_error(myconn->query.stmt));
} else {
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,client_myds->pkt_sid+1, 2013, (char *)"" ,(char *)"Lost connection to MySQL server during query");
}
client_myds->pkt_sid++;
}
break;
Expand Down

0 comments on commit 3819fb2

Please sign in to comment.