Skip to content

Commit 8389473

Browse files
committed
return empty string if out_len is zero
1 parent 6375622 commit 8389473

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

cpp/src/gandiva/precompiled/time.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,11 +749,17 @@ char* castVARCHAR_timestamp_int64(int64 context, timestamp in, int64 length,
749749
if (length > timestamp_str_len) {
750750
*out_len = timestamp_str_len;
751751
}
752+
if (*out_len <= 0) {
753+
*out_len = 0;
754+
const char* empty_str = "";
755+
return const_cast<char*>(empty_str);
756+
}
752757
char* ret = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, *out_len));
753758
if (ret == nullptr) {
754759
gdv_fn_context_set_error_msg(context, "Could not allocate memory for output string");
755760
*out_len = 0;
756-
return nullptr;
761+
const char* empty_str = "";
762+
return const_cast<char*>(empty_str);
757763
}
758764
memcpy(ret, timestamp_str.data(), *out_len);
759765
return ret;

0 commit comments

Comments
 (0)