"Fixed invalid reads due to memory from 'first_comment' being freed from global 'stmt_info' #3427"

'CurrentQuery.QueryParserArgs.first_comment' needs to hold it's own copy
of 'first_comment', otherwise, the 'first_comment' from global 'stmt_info'
will be freed by 'Query_Info::end' at the end of the life of 'CurrentQuery'.
pull/3453/head
Javier Jaramago Fernández 5 years ago
parent 9e70e3918b
commit adb5ed6b28

@ -4440,12 +4440,10 @@ handler_again:
stmt_info=GloMyStmt->find_prepared_statement_by_stmt_id(CurrentQuery.stmt_global_id);
CurrentQuery.QueryLength=stmt_info->query_length;
CurrentQuery.QueryPointer=(unsigned char *)stmt_info->query;
// NOTE: Since 'first_comment' is part of the info used to
// compute 'stmt' hashes, it's required to be copied here.
// Not doing so will lead to a loop of 'PREPARE' and 'EXECUTE',
// since the correct prepared statement will never be found
// due to the missing information to compute the hash.
CurrentQuery.QueryParserArgs.first_comment=stmt_info->first_comment;
// NOTE: Update 'first_comment' with the the from the retrieved
// 'stmt_info' from the found prepared statement. 'CurrentQuery' requires its
// own copy of 'first_comment' because it will later be free by 'QueryInfo::end'.
CurrentQuery.QueryParserArgs.first_comment=strdup(stmt_info->first_comment);
previous_status.push(PROCESSING_STMT_EXECUTE);
NEXT_IMMEDIATE(PROCESSING_STMT_PREPARE);
if (CurrentQuery.stmt_global_id!=stmt_info->statement_id) {

Loading…
Cancel
Save