paleolimbot commented on code in PR #955:
URL: https://github.com/apache/arrow-nanoarrow/pull/955#discussion_r4254376755


##########
src/nanoarrow/ipc/decoder.c:
##########
@@ -337,16 +337,74 @@ static ArrowErrorCode ArrowIpcDictionaryReplace(struct 
ArrowIpcDictionary* dicti
   return NANOARROW_OK;
 }
 
+// Point dictionaries of dst (and its children) at those of src, which reflect
+// the most recent value of any nested dictionaries.
+static ArrowErrorCode ArrowIpcArraySetDictionaries(struct ArrowArray* dst,
+                                                   const struct ArrowArray* 
src) {
+  if (src->dictionary != NULL) {
+    NANOARROW_DCHECK(dst->dictionary != NULL);
+    if (dst->dictionary->release != NULL) {
+      ArrowArrayRelease(dst->dictionary);
+    }
+    NANOARROW_RETURN_NOT_OK(ArrowArrayCloneShared(src->dictionary, 
dst->dictionary));
+  }
+
+  for (int64_t i = 0; i < src->n_children; i++) {
+    NANOARROW_RETURN_NOT_OK(
+        ArrowIpcArraySetDictionaries(dst->children[i], src->children[i]));
+  }
+
+  return NANOARROW_OK;
+}
+
+// Append the values of current and then value into combined, which must have 
been
+// initialized from array_view. array_view is used as scratch space to view 
current
+// and value.
+static ArrowErrorCode ArrowIpcDictionaryConcatenate(struct ArrowArray* 
combined,
+                                                    const struct ArrowArray* 
current,
+                                                    const struct ArrowArray* 
value,
+                                                    struct ArrowArrayView* 
array_view,
+                                                    struct ArrowError* error) {
+  NANOARROW_RETURN_NOT_OK_WITH_ERROR(ArrowArrayStartAppending(combined), 
error);
+  NANOARROW_RETURN_NOT_OK_WITH_ERROR(
+      ArrowArrayReserve(combined, current->length + value->length), error);

Review Comment:
   Codex kindly reminded me here that the two lengths here could overflow, so 
somebody who has run out of all of the normal ways to make software crash could 
provide huge null-typed dictionaries and make this unpredictable/crash.
   
   I think we have plenty of places already where we assume two lengths won't 
overflow an int64; however, if this is easy to fix it would be good to do it 
here.



-- 
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]

Reply via email to