github-actions[bot] commented on code in PR #68244:
URL: https://github.com/apache/doris/pull/68244#discussion_r4056137433
##########
be/src/util/jsonb_utils.h:
##########
@@ -162,7 +162,9 @@ class JsonbToJson {
return;
}
char char_buffer[16];
- for (const char* ptr = str; ptr != str + len && *ptr; ++ptr) {
+ // A JSON string may legally contain U+0000, so the loop must be
bounded by
+ // the length only; the NUL itself is escaped as \u0000 by the default
branch.
+ for (const char* ptr = str; ptr != str + len; ++ptr) {
Review Comment:
[P1] Preserve the stored length for a trailing U+0000
This loop is length-bounded now, but `intern_json()` still calls it with
`JsonbStringVal::length()` (lines 110-111). That helper returns
`strnlen(payload, size)` whenever the last stored byte is zero. As a result,
`{"key":"a\u0000"}` is stored as the two-byte payload `a,0` but reaches this
loop with `len == 1` and still renders as `{"key":"a"}`; a value containing
only `\u0000` becomes empty. All new tests put `b` after the NUL, so they miss
this branch. Please use the authoritative payload length here (for example,
`getBlobLen()` in the `T_String` case, while handling any typed padding at its
type-aware producer) and add trailing/only-NUL coverage.
--
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]