timmyb32r commented on code in PR #11932:
URL: https://github.com/apache/arrow-rs/pull/11932#discussion_r4406108015
##########
arrow-schema/src/ffi.rs:
##########
@@ -184,16 +184,36 @@ impl FFI_ArrowSchema {
Ok(this)
}
- /// Set the name of the schema
+ /// Set the name of the schema.
+ ///
+ /// # Errors
+ ///
+ /// Returns an error if `name` contains an interior nul byte, or if the
schema
+ /// does not use this crate's original release callback. Empty schemas and
+ /// schemas with a replaced release callback cannot be renamed.
pub fn with_name(mut self, name: &str) -> Result<Self, ArrowError> {
- self.name = CString::new(name)
- .map_err(|e| {
- ArrowError::CDataInterface(format!(
- "Null byte at position {} not allowed in name",
- e.nul_position()
- ))
- })?
- .into_raw();
+ if !self.release.is_some_and(|release| {
+ std::ptr::fn_addr_eq(
+ release,
+ release_schema as unsafe extern "C" fn(*mut FFI_ArrowSchema),
+ )
Review Comment:
Thanks for catching this! I checked — there really is a problem here. Still
thinking about the best way to fix it.
--
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]