Skip to content

Commit ba03c70

Browse files
committed
Fix segfault in audit plugin codepath
Summary: The THD pointer is not always available when the audit plugin is called. The causes a problem when we try to access thd->query_id. Fix by doing a null check first. If the THD is null, then we copy what is done for thread_id, we just set query_id to 0. Squash with: 1def6b7 Expose more information to audit plugin Test Plan: mtr Reviewers: jkedgar, hermanlee4, drilibo Reviewed By: drilibo Subscribers: webscalesql-eng Differential Revision: https://reviews.facebook.net/D58287
1 parent e6680d0 commit ba03c70

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sql/sql_audit.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static void general_class_handler(THD *thd, uint event_subtype, va_list ap)
9292
event.database_length= va_arg(ap, unsigned int);
9393
event.query_attributes= va_arg(ap, const char*);
9494
event.query_attributes_length= va_arg(ap, unsigned int);
95-
event.query_id= (unsigned long long) thd->query_id;
95+
event.query_id= thd ? (unsigned long long) thd->query_id : 0LL;
9696
event_class_dispatch(thd, MYSQL_AUDIT_GENERAL_CLASS, &event);
9797
}
9898

0 commit comments

Comments
 (0)