From e3587ec77d58da7dd6b1cff8b39078d4ddbe8e11 Mon Sep 17 00:00:00 2001 From: yangjiang Date: Thu, 16 Mar 2023 19:52:16 +0800 Subject: [PATCH] [cache] fix memory leak when erase key --- src/cache/lru.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cache/lru.rs b/src/cache/lru.rs index 74449cf..87832f2 100644 --- a/src/cache/lru.rs +++ b/src/cache/lru.rs @@ -224,6 +224,11 @@ where cb(key, &(*n.value.as_ptr())); } } + // should manually drop kv [MaybeUninit] + unsafe { + ptr::drop_in_place(n.key.as_mut_ptr()); + ptr::drop_in_place(n.value.as_mut_ptr()); + } } }