Copilot commented on code in PR #895:
URL: https://github.com/apache/arrow-nanoarrow/pull/895#discussion_r3676273161
##########
src/nanoarrow/ipc/decoder.c:
##########
@@ -325,7 +325,11 @@ static ArrowErrorCode ArrowIpcDictionaryReplace(struct
ArrowIpcDictionary* dicti
ArrowArrayRelease(&dictionary->current_value);
}
- ArrowArrayMove(value, &dictionary->current_value);
+ // Convert to a shared array so that clones can reference the same data
+ // without copying
+ struct ArrowArray shared;
+ NANOARROW_RETURN_NOT_OK(ArrowArrayMoveShared(value, &shared));
+ ArrowArrayMove(&shared, &dictionary->current_value);
Review Comment:
ArrowArrayMoveShared() can fail after it has already consumed `*value`
(setting value->release = NULL). In that case callers that unconditionally
ArrowArrayRelease(value) will crash, and the local `shared` may also hold
partially-initialized allocations that need cleanup. Handle the error
explicitly: zero-init `shared`, release it if partially built, and make
`*value` safe for the caller to release when it was consumed.
This issue also appears in the following locations of the same file:
- line 441
- line 2387
--
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]