[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

@ -291,6 +291,9 @@ TEST_F(StringFunctionsTest, null_or_empty) {
TEST_F(StringFunctionsTest, substring) {
doris_udf::FunctionContext* context = new doris_udf::FunctionContext();
ASSERT_EQ(AnyValUtil::from_string_temp(context, std::string("")),
StringFunctions::substring(context, StringVal("hello word"), 0, 5));
ASSERT_EQ(AnyValUtil::from_string_temp(context, std::string("hello")),
StringFunctions::substring(context, StringVal("hello word"), 1, 5));