[fix](be): fix stack overflow in unhex function (#11204)

* [fix](be): fix stack overflow in unhex function
This commit is contained in:
spaces-x
2022-07-28 14:59:54 +08:00
committed by GitHub
parent 19b34c09b1
commit b260a02215
4 changed files with 12 additions and 6 deletions

View File

@ -381,7 +381,8 @@ StringVal MathFunctions::unhex(FunctionContext* ctx, const StringVal& s) {
}
int result_len = s.len / 2;
char result[result_len];
StringVal result_string_val(ctx, result_len);
char* result = reinterpret_cast<char*>(result_string_val.ptr);
int res_index = 0;
int s_index = 0;
while (s_index < s.len) {
@ -426,7 +427,7 @@ StringVal MathFunctions::unhex(FunctionContext* ctx, const StringVal& s) {
result[res_index] = c;
++res_index;
}
return AnyValUtil::from_buffer_temp(ctx, result, result_len);
return result_string_val;
}
StringVal MathFunctions::conv_int(FunctionContext* ctx, const BigIntVal& num,