diff options
author | Martin Hansson <martin.hansson@oracle.com> | 2011-01-13 08:57:15 +0100 |
---|---|---|
committer | Martin Hansson <martin.hansson@oracle.com> | 2011-01-13 08:57:15 +0100 |
commit | 716b64cdb050ff9a22457990f336ef20a7b3663a (patch) | |
tree | 6cc0a92d31d0e672ac9851fa8ba338d0633a5547 /sql/item_strfunc.h | |
parent | a581444c0552c16712c961d62ba6947bcded4985 (diff) | |
download | mariadb-git-716b64cdb050ff9a22457990f336ef20a7b3663a.tar.gz |
Bug#58165: "my_empty_string" gets modified and causes LOAD DATA to fail and
other crashes
Some string manipulating SQL functions use a shared string object intended to
contain an immutable empty string. This object was used by the SQL function
SUBSTRING_INDEX() to return an empty string when one argument was of the wrong
datatype. If the string object was then modified by the sql function INSERT(),
undefined behavior ensued.
Fixed by instead modifying the string object representing the function's
result value whenever string manipulating SQL functions return an empty
string.
Relevant code has also been documented.
Diffstat (limited to 'sql/item_strfunc.h')
-rw-r--r-- | sql/item_strfunc.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index ab2bf006032..6645a4c637a 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -22,6 +22,16 @@ class Item_str_func :public Item_func { +protected: + /** + Sets the result value of the function an empty string, using the current + character set. No memory is allocated. + @retval A pointer to the str_value member. + */ + String *make_empty_result() { + str_value.set("", 0, collation.collation); + return &str_value; + } public: Item_str_func() :Item_func() { decimals=NOT_FIXED_DEC; } Item_str_func(Item *a) :Item_func(a) {decimals=NOT_FIXED_DEC; } |