Skip to content

Commit 3031723

Browse files
authored
Fix a memory leak in TitanDBOptions::set_dirname (#395)
Found via valgrind. Signed-off-by: Brian Anderson <[email protected]>
1 parent 79dee63 commit 3031723

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/titan.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ impl TitanDBOptions {
3333

3434
pub fn set_dirname(&mut self, name: &str) {
3535
let s = CString::new(name).unwrap();
36+
// Safety: set_dirname copies the C string into std::string. We
37+
// still own s and must drop it.
3638
unsafe {
37-
crocksdb_ffi::ctitandb_options_set_dirname(self.inner, s.into_raw());
39+
crocksdb_ffi::ctitandb_options_set_dirname(self.inner, s.as_ptr());
3840
}
3941
}
4042

0 commit comments

Comments
 (0)