diff options
-rw-r--r-- | dbug/dbug.c | 10 | ||||
-rw-r--r-- | mysql-test/r/variables_debug.result | 13 | ||||
-rw-r--r-- | mysql-test/t/variables_debug.test | 13 |
3 files changed, 36 insertions, 0 deletions
diff --git a/dbug/dbug.c b/dbug/dbug.c index baf080f5e27..30ad6c2c6d1 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -455,6 +455,13 @@ static void DbugParse(CODE_STATE *cs, const char *control) rel= control[0] == '+' || control[0] == '-'; if ((!rel || (!stack->out_file && !stack->next))) { + /* + We need to free what's already in init_settings, because unlike + the thread related stack frames there's a chance that something + is in these variables already. + */ + if (stack == &init_settings) + FreeState(cs, stack, 0); stack->flags= 0; stack->delay= 0; stack->maxdepth= 0; @@ -1510,7 +1517,10 @@ void _db_end_() while ((discard= cs->stack)) { if (discard == &init_settings) + { + FreeState (cs, discard, 0); break; + } cs->stack= discard->next; FreeState(cs, discard, 1); } diff --git a/mysql-test/r/variables_debug.result b/mysql-test/r/variables_debug.result index 9cd133dddb1..85eaf34b033 100644 --- a/mysql-test/r/variables_debug.result +++ b/mysql-test/r/variables_debug.result @@ -10,3 +10,16 @@ set debug= '-P'; select @@debug; @@debug T +# +# Bug #52629: memory leak from sys_var_thd_dbug in +# binlog.binlog_write_error +# +SET GLOBAL debug='d,injecting_fault_writing'; +SELECT @@global.debug; +@@global.debug +d,injecting_fault_writing +SET GLOBAL debug=''; +SELECT @@global.debug; +@@global.debug + +End of 5.1 tests diff --git a/mysql-test/t/variables_debug.test b/mysql-test/t/variables_debug.test index 7dcaf246803..8f2bde7ae42 100644 --- a/mysql-test/t/variables_debug.test +++ b/mysql-test/t/variables_debug.test @@ -10,3 +10,16 @@ set debug= '+P'; select @@debug; set debug= '-P'; select @@debug; + +--echo # +--echo # Bug #52629: memory leak from sys_var_thd_dbug in +--echo # binlog.binlog_write_error +--echo # + +SET GLOBAL debug='d,injecting_fault_writing'; +SELECT @@global.debug; +SET GLOBAL debug=''; +SELECT @@global.debug; + + +--echo End of 5.1 tests |