Skip to content

Commit ea3756a

Browse files
author
Tor Didriksen
committed
Bug#22151233 MEMORY LEAKS WHEN DOING INSERT... UPDATE ... PREPARED STATEMENTS
Problem: memory leaks when doing INSERT... UPDATE ... prepared statements. Regression source is patch for Bug#21908206 MEMORY LEAK ON WINDOWS WHEN SELECT FROM VIEW IN SUBQUERY Which fixed a regression caused by Bug#13901905 - CRASH: INSERT ON DUPLICATE KEY UPDATE READS FREED MEMORY The patch for Bug#21908206 fixed a leak for LEX objects that were not properly destroyed. Solution: clear the std::map for LEX objects thar *are* destroyed.
1 parent 1ffffac commit ea3756a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

sql/sql_lex.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3528,6 +3528,7 @@ LEX::LEX()
35283528
plugins(PSI_NOT_INSTRUMENTED),
35293529
insert_update_values_map(NULL),
35303530
option_type(OPT_DEFAULT),
3531+
sphead(NULL),
35313532
is_set_password_sql(false),
35323533
// Initialize here to avoid uninitialized variable warnings.
35333534
contains_plaintext_password(false),

sql/sql_prepare.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3105,8 +3105,10 @@ Prepared_statement::~Prepared_statement()
31053105
free_items();
31063106
if (lex)
31073107
{
3108+
DBUG_ASSERT(lex->sphead == NULL);
3109+
lex_end(lex);
31083110
delete lex->result;
3109-
delete (st_lex_local *) lex;
3111+
delete (st_lex_local *) lex; // TRASH memory
31103112
}
31113113
free_root(&main_mem_root, MYF(0));
31123114
DBUG_VOID_RETURN;

0 commit comments

Comments
 (0)