Skip to content

Commit ea494f5

Browse files
roylysengdahlerlend
authored andcommitted
Bug#33016004: Problem when calling audit_log_filter_flush() in a prepared stmt
Followup fix. initid.const_item may be changed by the called init function, thus calling the deinit function may be done based on a bad value. Fixed by saving the value of initid.const_item before calling the init function and using this value to decide whether to call deinit. Reviewed by: Gleb Shchepa <[email protected]> Change-Id: I05a54916fc6c7c7f18b4268bf7eb2d5fd65bc409
1 parent 55e3013 commit ea494f5

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

sql/item_func.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4341,8 +4341,9 @@ void udf_handler::cleanup() {
43414341
if (thd->stmt_arena->is_stmt_prepare() && thd->stmt_arena->is_repreparing)
43424342
return;
43434343

4344-
if (initid.const_item && u_d->func_deinit != nullptr) {
4344+
if (m_init_func_called && u_d->func_deinit != nullptr) {
43454345
(*u_d->func_deinit)(&initid);
4346+
m_init_func_called = false;
43464347
}
43474348
DEBUG_SYNC(current_thd, "udf_handler_destroy_sync");
43484349
free_handler();
@@ -4566,6 +4567,7 @@ bool udf_handler::call_init_func() {
45664567
my_error(ER_CANT_INITIALIZE_UDF, MYF(0), u_d->name.str, init_msg_buff);
45674568
return true;
45684569
}
4570+
m_init_func_called = true;
45694571
return false;
45704572
}
45714573

sql/sql_udf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class udf_handler {
9090
uchar is_null{0};
9191
/// True when handler has been initialized and use count incremented
9292
bool m_initialized{false};
93+
/// True when init function has been called
94+
bool m_init_func_called{false};
9395
Item **args;
9496
Udf_args_extension m_args_extension; /**< A struct that holds the extension
9597
arguments for each UDF argument */

0 commit comments

Comments
 (0)