Skip to content

Commit 050e47f

Browse files
committed
Fix memory leak in Encryptable
1 parent 0b958b0 commit 050e47f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/encryptable.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl CblRef for Encryptable {
6666

6767
impl From<*mut CBLEncryptable> for Encryptable {
6868
fn from(cbl_ref: *mut CBLEncryptable) -> Self {
69-
Self::reference(cbl_ref)
69+
Self::take_ownership(cbl_ref)
7070
}
7171
}
7272

@@ -80,6 +80,11 @@ impl Encryptable {
8080
}
8181
}
8282

83+
/// Takes ownership of the CBL ref, the reference counter is not increased so dropping the instance will free the ref.
84+
pub(crate) const fn take_ownership(cbl_ref: *mut CBLEncryptable) -> Self {
85+
Self { cbl_ref }
86+
}
87+
8388
////////
8489

8590
/// Creates Encryptable object with null value.

0 commit comments

Comments
 (0)