Hongyang66666 commented on code in PR #58656:
URL: https://github.com/apache/doris/pull/58656#discussion_r2583860824


##########
be/src/util/jsonb_document.h:
##########
@@ -1042,6 +1042,11 @@ struct ArrayVal : public ContainerVal {
 inline Status JsonbDocument::checkAndCreateDocument(const char* pb, size_t 
size,
                                                     JsonbDocument** doc) {
     *doc = nullptr;
+    // Fix Issue #58523: Tolerate empty data from legacy versions, treat as 
NULL to avoid errors.

Review Comment:
   @yiguolei Thanks for the review! You are absolutely right.
   Returning OK with a nullptr doc will indeed cause a crash in the caller.
   I have updated the patch. Now, if size == 0, I initialize a static valid 
Null JsonbDocument (using JsonbWriter to construct it once) and assign it to 
*doc. This ensures the caller gets a safe, valid object representing a JSON 
null.
   Please verify the latest commit.



##########
be/src/util/jsonb_document.h:
##########
@@ -1042,6 +1042,11 @@ struct ArrayVal : public ContainerVal {
 inline Status JsonbDocument::checkAndCreateDocument(const char* pb, size_t 
size,
                                                     JsonbDocument** doc) {
     *doc = nullptr;
+    // Fix Issue #58523: Tolerate empty data from legacy versions, treat as 
NULL to avoid errors.
+    if (size == 0) {
+        return Status::OK();

Review Comment:
   @mrhhsg Thanks for the review! You are absolutely right.
   Returning OK with a nullptr doc will indeed cause a crash in the caller.
   I have updated the patch. Now, if size == 0, I initialize a static valid 
Null JsonbDocument (using JsonbWriter to construct it once) and assign it to 
*doc. This ensures the caller gets a safe, valid object representing a JSON 
null.
   Please verify the latest commit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to