diff options
author | bell@sanja.is.com.ua <> | 2005-06-28 21:45:11 +0300 |
---|---|---|
committer | bell@sanja.is.com.ua <> | 2005-06-28 21:45:11 +0300 |
commit | 0e30eea1414d694858e013e64cc17b493376c4eb (patch) | |
tree | 53a7c6eac183ba5acf820c263dca5abdbfd58eb5 /sql | |
parent | f230d35c6426d3282c5e3708f1bd5bf9021a99d6 (diff) | |
download | mariadb-git-0e30eea1414d694858e013e64cc17b493376c4eb.tar.gz |
fixed substring() length calculation in case of constant negative argument (BUG#10269)
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_strfunc.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 881a8a7c915..08e6a222c69 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1065,7 +1065,8 @@ void Item_func_substr::fix_length_and_dec() collation.set(args[0]->collation); if (args[1]->const_item()) { - int32 start=(int32) args[1]->val_int()-1; + int32 start= (int32) args[1]->val_int(); + start= (int32)((start < 0) ? max_length + start : start - 1); if (start < 0 || start >= (int32) max_length) max_length=0; /* purecov: inspected */ else |