diff options
author | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-09-22 23:33:18 +0400 |
---|---|---|
committer | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-09-22 23:33:18 +0400 |
commit | faf54ff95cfb4e32029cd1d30a1a643d79ce96ec (patch) | |
tree | ecfed3ad4c93790a5ce2ce97a44a165457c664d1 /dbug | |
parent | 0c74cc0d1097c51e9e54c6e0fb1550e4d3df84c7 (diff) | |
download | mariadb-git-faf54ff95cfb4e32029cd1d30a1a643d79ce96ec.tar.gz |
Bug #56709: Memory leaks at running the 5.1 test suite
Fixed a number of memory leaks discovered by valgrind.
dbug/dbug.c:
This is actually an addendum to the fix for bug #52629:
- there is no point in limiting the fix to just global
variables, session ones are also affected.
- zero all fields when allocating a new 'state' structure so
that FreeState() does not deal with unitialized data later.
- add a check for a NULL pointer in DBUGCloseFile()
mysql-test/r/partition_error.result:
Added a test case for bug #56709.
mysql-test/r/variables_debug.result:
Added a test case for bug #56709.
mysql-test/t/partition_error.test:
Added a test case for bug #56709.
mysql-test/t/variables_debug.test:
Added a test case for bug #56709.
sql/item_timefunc.cc:
There is no point in declaring 'value' as a member of
Item_extract and dynamically allocating memory for it in
Item_extract::fix_length_and_dec(), since this string is only
used as a temporary storage in Item_extract::val_int().
sql/item_timefunc.h:
Removed 'value' from the Item_extract class definition.
sql/sql_load.cc:
- we may need to deallocate 'buffer' even when 'error' is
non-zero in some cases, since 'error' is public, and there is
external code modifying it.
- assign NULL to buffer when deallocating it so that we don't
do it twice in the destructor
- there is no point in changing 'error' in the destructor.
Diffstat (limited to 'dbug')
-rw-r--r-- | dbug/dbug.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/dbug/dbug.c b/dbug/dbug.c index 8fa5ed9af6b..76723fa8767 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -455,13 +455,8 @@ 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); + /* Free memory associated with the state before resetting its members */ + FreeState(cs, stack, 0); stack->flags= 0; stack->delay= 0; stack->maxdepth= 0; @@ -1447,8 +1442,8 @@ static void PushState(CODE_STATE *cs) struct settings *new_malloc; new_malloc= (struct settings *) DbugMalloc(sizeof(struct settings)); + bzero(new_malloc, sizeof(struct settings)); new_malloc->next= cs->stack; - new_malloc->out_file= NULL; cs->stack= new_malloc; } @@ -1957,7 +1952,7 @@ static FILE *OpenProfile(CODE_STATE *cs, const char *name) static void DBUGCloseFile(CODE_STATE *cs, FILE *fp) { - if (fp != stderr && fp != stdout && fclose(fp) == EOF) + if (fp != NULL && fp != stderr && fp != stdout && fclose(fp) == EOF) { pthread_mutex_lock(&THR_LOCK_dbug); (void) fprintf(cs->stack->out_file, ERR_CLOSE, cs->process); |