Skip to content

Commit 89698ce

Browse files
committed
MDEV-10570: Fix -Wmaybe-uninitialized
Rows_log_event::change_to_flashback_event(): Reduce the scope of the variable swap_buff2, and do not duplicate conditions. GCC 9.3.0 flagged the -Wmaybe-uninitialized when compiling the 10.5 branch using cmake -DWITH_ASAN=ON -DCMAKE_CXX_FLAGS=-O2
1 parent b1d7ba4 commit 89698ce

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

sql/log_event.cc

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright (c) 2000, 2019, Oracle and/or its affiliates.
3-
Copyright (c) 2009, 2019, MariaDB
3+
Copyright (c) 2009, 2020, MariaDB
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -3184,7 +3184,7 @@ void Rows_log_event::change_to_flashback_event(PRINT_EVENT_INFO *print_event_inf
31843184
Table_map_log_event *map;
31853185
table_def *td;
31863186
DYNAMIC_ARRAY rows_arr;
3187-
uchar *swap_buff1, *swap_buff2;
3187+
uchar *swap_buff1;
31883188
uchar *rows_pos= rows_buff + m_rows_before_size;
31893189

31903190
if (!(map= print_event_info->m_table_map.get_table(m_table_id)) ||
@@ -3233,29 +3233,22 @@ void Rows_log_event::change_to_flashback_event(PRINT_EVENT_INFO *print_event_inf
32333233
}
32343234
value+= length2;
32353235

3236-
swap_buff2= (uchar *) my_malloc(length2, MYF(0));
3236+
void *swap_buff2= my_malloc(length2, MYF(0));
32373237
if (!swap_buff2)
32383238
{
32393239
fprintf(stderr, "\nError: Out of memory. "
32403240
"Could not exchange to flashback event.\n");
32413241
exit(1);
32423242
}
32433243
memcpy(swap_buff2, start_pos + length1, length2); // WHERE part
3244-
}
32453244

3246-
if (ev_type == UPDATE_ROWS_EVENT ||
3247-
ev_type == UPDATE_ROWS_EVENT_V1)
3248-
{
32493245
/* Swap SET and WHERE part */
32503246
memcpy(start_pos, swap_buff2, length2);
32513247
memcpy(start_pos + length2, swap_buff1, length1);
3248+
my_free(swap_buff2);
32523249
}
32533250

3254-
/* Free tmp buffers */
32553251
my_free(swap_buff1);
3256-
if (ev_type == UPDATE_ROWS_EVENT ||
3257-
ev_type == UPDATE_ROWS_EVENT_V1)
3258-
my_free(swap_buff2);
32593252

32603253
/* Copying one row into a buff, and pushing into the array */
32613254
LEX_STRING one_row;

0 commit comments

Comments
 (0)