summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-09-22 23:33:18 +0400
committerAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-09-22 23:33:18 +0400
commitfaf54ff95cfb4e32029cd1d30a1a643d79ce96ec (patch)
treeecfed3ad4c93790a5ce2ce97a44a165457c664d1 /sql
parent0c74cc0d1097c51e9e54c6e0fb1550e4d3df84c7 (diff)
downloadmariadb-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 'sql')
-rw-r--r--sql/item_timefunc.cc4
-rw-r--r--sql/item_timefunc.h1
-rw-r--r--sql/sql_load.cc12
3 files changed, 7 insertions, 10 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index dff4d20f347..103bd96efd4 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -2270,8 +2270,6 @@ void Item_extract::print(String *str, enum_query_type query_type)
void Item_extract::fix_length_and_dec()
{
- value.alloc(32); // alloc buffer
-
maybe_null=1; // If wrong date
switch (int_type) {
case INTERVAL_YEAR: max_length=4; date_value=1; break;
@@ -2314,6 +2312,8 @@ longlong Item_extract::val_int()
}
else
{
+ char buf[40];
+ String value(buf, sizeof(buf), &my_charset_bin);;
String *res= args[0]->val_str(&value);
if (!res || str_to_time_with_warn(res->ptr(), res->length(), &ltime))
{
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 11eed70f399..ef86406e1be 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -702,7 +702,6 @@ public:
class Item_extract :public Item_int_func
{
- String value;
bool date_value;
public:
const interval_type int_type; // keep it public
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index f9386206dce..4b68f2a3821 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -1116,6 +1116,7 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs,
MYF(MY_WME)))
{
my_free((uchar*) buffer,MYF(0)); /* purecov: inspected */
+ buffer= NULL;
error=1;
}
else
@@ -1142,13 +1143,10 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs,
READ_INFO::~READ_INFO()
{
- if (!error)
- {
- if (need_end_io_cache)
- ::end_io_cache(&cache);
- my_free((uchar*) buffer,MYF(0));
- error=1;
- }
+ if (!error && need_end_io_cache)
+ ::end_io_cache(&cache);
+
+ my_free(buffer, MYF(MY_ALLOW_ZERO_PTR));
}