[BUG] Fixed the problem that substring function may access illegal address (#5952)

This commit is contained in:
stdpain
2021-06-03 18:38:10 +08:00
committed by GitHub
parent 4ef1dbf394
commit d790cc6a50
2 changed files with 4 additions and 1 deletions

View File

@ -69,7 +69,7 @@ StringVal StringFunctions::substring(FunctionContext* context, const StringVal&
if (str.is_null || pos.is_null || len.is_null || pos.val > str.len) {
return StringVal::null();
}
if (len.val <= 0 || str.len == 0) {
if (len.val <= 0 || str.len == 0 || pos.val == 0) {
return StringVal();
}