-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
'merge_sort::merge()' crashes with double-free for T: Drop
#1
Comments
Heads up: this issue has been included in the RustSec advisory database. It will be surfaced by tools such as cargo-audit or cargo-deny from now on. Once a fix is released to crates.io, please open a pull request to update the advisory with the patched version, or file an issue on the advisory database repository. |
Why was this issue closed? |
This still reproduces with the given test case using the current release on crates.io (algorithmica 0.1.9) or the current Git |
@yvt, It is closed by mistake. |
Hello,
we (Rust group @sslab-gatech) found a memory-safety/soundness issue in this crate while scanning Rust code on crates.io for potential vulnerabilities.
Issue Description
The implementation of
merge_sort::merge()
freely duplicates ownership of items fromlist
, and invokes drop of the duplicated items vialist[k] = ..
.Also, panic within
compare()
can trigger double-free of items whose ownership was duplicated via.read()
.algorithmica/algorithmica/src/sort/merge_sort.rs
Lines 9 to 55 in d8fef16
Reproduction
Below is an example program that exhibits undefined behavior using safe APIs of
algorithmica
. Simply callingmerge_sort::sort()
on an array ofT: Drop
triggersdouble-free.
Show Detail
Output:
Tested Environment
The text was updated successfully, but these errors were encountered: