Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double free in C Stream Interface #4659

Closed
wjones127 opened this issue Aug 7, 2023 · 1 comment · Fixed by #4660
Closed

Double free in C Stream Interface #4659

wjones127 opened this issue Aug 7, 2023 · 1 comment · Fixed by #4660
Assignees
Labels
arrow Changes to the arrow crate bug

Comments

@wjones127
Copy link
Member

Describe the bug

Got a double free when consuming a stream and trying to return the error. Right now the C Stream Interface import tries to take ownership of the error string, but once the release callback is called that string gets freed.

let error_str = unsafe {
let c_str =
self.stream.get_last_error.unwrap()(&mut self.stream) as *mut c_char;
CString::from_raw(c_str).into_string()
};
if let Err(err) = error_str {
Some(err.to_string())
} else {
Some(error_str.unwrap())
}

From the C stream interface docs:

The returned pointer is only guaranteed to be valid until the next call of one of the stream’s callbacks. The character string it points to should be copied to consumer-managed storage if it is intended to survive longer.

To Reproduce

Expected behavior

We should probably clone the string as suggested by the interface docs.

Additional context

@tustvold
Copy link
Contributor

label_issue.py automatically added labels {'arrow'} from #4660

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants