[fix](hash join) fix stack overflow caused by evaluate case expr on huge build block (#28851)
This commit is contained in:
@ -582,6 +582,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static constexpr int MAX_STACK_CIPHER_LEN = 1024 * 64;
|
||||
struct UnHexImpl {
|
||||
static constexpr auto name = "unhex";
|
||||
using ReturnType = DataTypeString;
|
||||
@ -654,8 +655,16 @@ struct UnHexImpl {
|
||||
continue;
|
||||
}
|
||||
|
||||
char dst_array[MAX_STACK_CIPHER_LEN];
|
||||
char* dst = dst_array;
|
||||
|
||||
int cipher_len = srclen / 2;
|
||||
char dst[cipher_len];
|
||||
std::unique_ptr<char[]> dst_uptr;
|
||||
if (cipher_len > MAX_STACK_CIPHER_LEN) {
|
||||
dst_uptr.reset(new char[cipher_len]);
|
||||
dst = dst_uptr.get();
|
||||
}
|
||||
|
||||
int outlen = hex_decode(source, srclen, dst);
|
||||
|
||||
if (outlen < 0) {
|
||||
@ -725,8 +734,16 @@ struct ToBase64Impl {
|
||||
continue;
|
||||
}
|
||||
|
||||
char dst_array[MAX_STACK_CIPHER_LEN];
|
||||
char* dst = dst_array;
|
||||
|
||||
int cipher_len = (int)(4.0 * ceil((double)srclen / 3.0));
|
||||
char dst[cipher_len];
|
||||
std::unique_ptr<char[]> dst_uptr;
|
||||
if (cipher_len > MAX_STACK_CIPHER_LEN) {
|
||||
dst_uptr.reset(new char[cipher_len]);
|
||||
dst = dst_uptr.get();
|
||||
}
|
||||
|
||||
int outlen = base64_encode((const unsigned char*)source, srclen, (unsigned char*)dst);
|
||||
|
||||
if (outlen < 0) {
|
||||
@ -765,8 +782,15 @@ struct FromBase64Impl {
|
||||
continue;
|
||||
}
|
||||
|
||||
char dst_array[MAX_STACK_CIPHER_LEN];
|
||||
char* dst = dst_array;
|
||||
|
||||
int cipher_len = srclen;
|
||||
char dst[cipher_len];
|
||||
std::unique_ptr<char[]> dst_uptr;
|
||||
if (cipher_len > MAX_STACK_CIPHER_LEN) {
|
||||
dst_uptr.reset(new char[cipher_len]);
|
||||
dst = dst_uptr.get();
|
||||
}
|
||||
int outlen = base64_decode(source, srclen, dst);
|
||||
|
||||
if (outlen < 0) {
|
||||
|
||||
Reference in New Issue
Block a user