rust-rocksdb
rust-rocksdb copied to clipboard
simplify impl of read table properties
Rudra complains about the potential double-free issue https://paper.seebug.org/1728/#05-panic-safety-double-free-rustsec-2021-0011, so simplify it to avoid using mem::forgot
// Warning (UnsafeDataflow:/ReadFlow): Potential unsafe dataflow issue in
// `rocksdb::SstFileReader::read_table_properties::callback`
// -> src/rocksdb.rs:2330:9: 2338:10
extern "C" fn callback<F: FnOnce(&TableProperties)>(
ctx: *mut c_void,
ptr: *const crocksdb_ffi::DBTableProperties,
) {
unsafe {
let caller = ptr::read(ctx as *mut F);
caller(TableProperties::from_ptr(ptr));
}
}
/test
/build