summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-03-17 10:32:42 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-03-17 10:35:56 +0200
commit89698cef72a5c220a2fcc346e3dd975ae219b7d9 (patch)
treea39602b3883a2f8f7d1fde8d6733a364a4685dda
parentb1d7ba472e434a75f7c17d932f50335963d87283 (diff)
downloadmariadb-git-89698cef72a5c220a2fcc346e3dd975ae219b7d9.tar.gz
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
-rw-r--r--sql/log_event.cc15
1 files changed, 4 insertions, 11 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 29cb4d6d7d7..a3ebf530796 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2019, Oracle and/or its affiliates.
- Copyright (c) 2009, 2019, MariaDB
+ Copyright (c) 2009, 2020, MariaDB
This program is free software; you can redistribute it and/or modify
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
Table_map_log_event *map;
table_def *td;
DYNAMIC_ARRAY rows_arr;
- uchar *swap_buff1, *swap_buff2;
+ uchar *swap_buff1;
uchar *rows_pos= rows_buff + m_rows_before_size;
if (!(map= print_event_info->m_table_map.get_table(m_table_id)) ||
@@ -3233,7 +3233,7 @@ void Rows_log_event::change_to_flashback_event(PRINT_EVENT_INFO *print_event_inf
}
value+= length2;
- swap_buff2= (uchar *) my_malloc(length2, MYF(0));
+ void *swap_buff2= my_malloc(length2, MYF(0));
if (!swap_buff2)
{
fprintf(stderr, "\nError: Out of memory. "
@@ -3241,21 +3241,14 @@ void Rows_log_event::change_to_flashback_event(PRINT_EVENT_INFO *print_event_inf
exit(1);
}
memcpy(swap_buff2, start_pos + length1, length2); // WHERE part
- }
- if (ev_type == UPDATE_ROWS_EVENT ||
- ev_type == UPDATE_ROWS_EVENT_V1)
- {
/* Swap SET and WHERE part */
memcpy(start_pos, swap_buff2, length2);
memcpy(start_pos + length2, swap_buff1, length1);
+ my_free(swap_buff2);
}
- /* Free tmp buffers */
my_free(swap_buff1);
- if (ev_type == UPDATE_ROWS_EVENT ||
- ev_type == UPDATE_ROWS_EVENT_V1)
- my_free(swap_buff2);
/* Copying one row into a buff, and pushing into the array */
LEX_STRING one_row;