This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch dev-1.0.0
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git

commit 536c03bdf750fc27147fc342a58d6c4affae1bff
Author: Zhengguo Yang <yangz...@gmail.com>
AuthorDate: Fri Mar 18 11:27:28 2022 +0800

    [fix] fix String type comapaction or agg may crash when string is null 
(#8515)
---
 be/src/olap/field.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/be/src/olap/field.h b/be/src/olap/field.h
index 1353723..f306e2d 100644
--- a/be/src/olap/field.h
+++ b/be/src/olap/field.h
@@ -85,7 +85,7 @@ public:
 
     inline void agg_update(RowCursorCell* dest, const RowCursorCell& src,
                            MemPool* mem_pool = nullptr) const {
-        if (type() == OLAP_FIELD_TYPE_STRING && mem_pool == nullptr) {
+        if (type() == OLAP_FIELD_TYPE_STRING && mem_pool == nullptr && 
!src.is_null()) {
             auto dst_slice = 
reinterpret_cast<Slice*>(dest->mutable_cell_ptr());
             auto src_slice = reinterpret_cast<const Slice*>(src.cell_ptr());
             if (dst_slice->size < src_slice->size) {
@@ -247,7 +247,7 @@ public:
     // used by init scan key stored in string format
     // value_string should end with '\0'
     inline OLAPStatus from_string(char* buf, const std::string& value_string) 
const {
-        if (type() == OLAP_FIELD_TYPE_STRING) {
+        if (type() == OLAP_FIELD_TYPE_STRING && !value_string.empty()) {
             auto slice = reinterpret_cast<Slice*>(buf);
             if (slice->size < value_string.size()) {
                 *_long_text_buf = static_cast<char*>(realloc(*_long_text_buf, 
value_string.size()));

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to