summaryrefslogtreecommitdiff
path: root/sql/item_buff.cc
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2006-10-11 19:44:12 +0400
committerunknown <evgen@moonbone.local>2006-10-11 19:44:12 +0400
commitb6248f76ed201d524ccc9b33cae2d961a0724c5e (patch)
tree667f42f01a14de899bbf9ac1ddaf182fd644b46d /sql/item_buff.cc
parent09dfd9e7e4925b357e090a133d6e38e355dda3f5 (diff)
downloadmariadb-git-b6248f76ed201d524ccc9b33cae2d961a0724c5e.tar.gz
Bug#22138: Unhandled NULL caused server crash
The Cached_item_decimal::cmp() method wasn't checking for null pointer returned from the val_decimal() of the item being cached. This leads to server crash. The Cached_item_decimal::cmp() method now check for null values. sql/item_buff.cc: Bug#22138: Unhandled NULL caused server crash The Cached_item_decimal::cmp() method now check for null values. mysql-test/r/type_decimal.result: Added the test case for bug#22138: Unhandled NULL caused server crash mysql-test/t/type_decimal.test: Added the test case for bug#22138: Unhandled NULL caused server crash
Diffstat (limited to 'sql/item_buff.cc')
-rw-r--r--sql/item_buff.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/sql/item_buff.cc b/sql/item_buff.cc
index 1661f04a4ae..37f9ca7ce6c 100644
--- a/sql/item_buff.cc
+++ b/sql/item_buff.cc
@@ -132,11 +132,17 @@ bool Cached_item_decimal::cmp()
{
my_decimal tmp;
my_decimal *ptmp= item->val_decimal(&tmp);
- if (null_value != item->null_value || my_decimal_cmp(&value, ptmp))
+ if (null_value != item->null_value ||
+ (!item->null_value && my_decimal_cmp(&value, ptmp)))
{
null_value= item->null_value;
- my_decimal2decimal(ptmp, &value);
- return TRUE;
+ /* Save only not null values */
+ if (!null_value)
+ {
+ my_decimal2decimal(ptmp, &value);
+ return TRUE;
+ }
+ return FALSE;
}
return FALSE;
}