From 3f75ed9eee00ea03bae07e059b3dddc0d90f7395 Mon Sep 17 00:00:00 2001 From: Riccardo Mazzarini Date: Thu, 6 Apr 2023 00:53:54 +0200 Subject: [PATCH] (types): don't de-allocate a `String` when it gets dropped --- crates/nvim-types/src/string.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/nvim-types/src/string.rs b/crates/nvim-types/src/string.rs index da657a29..4d9ae978 100644 --- a/crates/nvim-types/src/string.rs +++ b/crates/nvim-types/src/string.rs @@ -154,10 +154,11 @@ impl Clone for String { impl Drop for String { fn drop(&mut self) { - // One extra for null terminator. - let _ = unsafe { - Vec::from_raw_parts(self.data, self.size + 1, self.size + 1) - }; + // There's no way to know if the pointer we get from Neovim + // points to some `malloc`ed memory or to a static/borrowed string. + // + // TODO: we're leaking memory here if the pointer points to allocated + // memory. } }