Skip to content

Commit e053345

Browse files
authored
Merge pull request #1 from cstorey/master
Fix two memory safety issues.
2 parents bd19d5b + f5ec036 commit e053345

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/dbi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ impl<'a> Database<'a> {
568568
env::env_ptr(env), ptr::null_mut(), 0, &mut raw_tx));
569569
let mut wrapped_tx = TxHandle(raw_tx); // For auto-closing etc
570570
lmdb_call!(ffi::mdb_dbi_open(
571-
raw_tx, name_cstr.map_or(ptr::null(), |s| s.as_ptr()),
571+
raw_tx, name_cstr.as_ref().map_or(ptr::null(), |s| s.as_ptr()),
572572
options.flags.bits(), &mut raw));
573573

574574
if !locked_dbis.insert(raw) {

src/tx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ impl Drop for TxHandle {
259259

260260
impl TxHandle {
261261
pub unsafe fn commit(&mut self) -> Result<()> {
262-
lmdb_call!(ffi::mdb_txn_commit(self.0));
263-
self.0 = ptr::null_mut();
262+
let txn_p = mem::replace(&mut self.0, ptr::null_mut());
263+
lmdb_call!(ffi::mdb_txn_commit(txn_p));
264264
Ok(())
265265
}
266266
}

0 commit comments

Comments
 (0)