Copilot commented on code in PR #862:
URL: https://github.com/apache/iceberg-cpp/pull/862#discussion_r3687652901
##########
src/iceberg/schema_internal.cc:
##########
@@ -218,6 +218,7 @@ Status ToArrowSchema(const Schema& schema, ArrowSchema*
out) {
if (ArrowErrorCode errorCode = ToArrowSchema(schema, /*optional=*/false,
/*name=*/"",
/*field_id=*/std::nullopt, out);
errorCode != NANOARROW_OK) {
+ ArrowSchemaRelease(out);
return InvalidSchema(
"Failed to convert Iceberg schema to Arrow schema, error code: {}",
errorCode);
}
Review Comment:
`ArrowSchemaRelease(out)` is called unconditionally on conversion failure.
Elsewhere in the codebase release calls are guarded by `schema->release !=
nullptr` (e.g., ArrowSchemaGuard/ManifestEntryAdapter), which suggests
`ArrowSchemaRelease()` may assume a non-null release callback. If nanoarrow
returns an error before setting `out->release`, this could dereference a null
function pointer. Consider guarding the release call and explicitly zeroing the
output so callers don’t observe dangling pointers after failure.
--
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]