summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authorGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2010-12-16 18:44:17 +0200
committerGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2010-12-16 18:44:17 +0200
commitc6b904abf8a139a3b95c9825cc7c53fd8f1a6fd0 (patch)
treea0d8f4957cf9d256a3cc3445c7db25384f97e249 /sql/item_strfunc.cc
parent28a5059a92707e009aada358bf103fa386ea7c2c (diff)
parent3d799bdffd04beba3dad4f1ece915104b0284157 (diff)
downloadmariadb-git-c6b904abf8a139a3b95c9825cc7c53fd8f1a6fd0.tar.gz
merge mysql-5.5->mysql-5.5-bugteam
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 3c92c829144..2a93bcd0153 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1080,9 +1080,15 @@ String *Item_func_replace::val_str(String *str)
search=res2->ptr();
search_end=search+from_length;
redo:
+ DBUG_ASSERT(res->ptr() || !offset);
ptr=res->ptr()+offset;
strend=res->ptr()+res->length();
- end=strend-from_length+1;
+ /*
+ In some cases val_str() can return empty string
+ with ptr() == NULL and length() == 0.
+ Let's check strend to avoid overflow.
+ */
+ end= strend ? strend - from_length + 1 : NULL;
while (ptr < end)
{
if (*ptr == *search)