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

fix: merge delete_callback omitted by mistake #500

Merged

Conversation

zhangsoledad
Copy link
Contributor

@zhangsoledad zhangsoledad commented Feb 22, 2021

#457 make a change

The merge result Vec is turned into a boxed slice and turned into raw pointer by Box::into_raw. In delete_callback, Box::from_raw is called to wrap the raw pointer back and the original memory will be released here.

#481 omit delete_callback by mistake.

According

if (delete_value_ != nullptr) {
      (*delete_value_)(state_, tmp_new_value, new_value_len);
} else {
      free(tmp_new_value);
}

https://doc.rust-lang.org/std/boxed/struct.Box.html#method.into_raw
https://doc.rust-lang.org/nomicon/ffi.html#destructors
I think this is UB.

fix #494

Copy link
Member

@stanislav-tkach stanislav-tkach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@aleksuss aleksuss merged commit 39b877b into rust-rocksdb:master Feb 23, 2021
@zhangsoledad zhangsoledad deleted the zhangsoledad/fix-upstream-merge-ub branch February 23, 2021 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

merge operator delete_callback
3 participants