From 0d721bf0e615a8e62444915bce3604eaa0b9fd55 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 25 Aug 2021 15:13:07 +0200 Subject: [PATCH] fix return value of `Pool::grow` on x86_64 the logic was increasing the "capacity" counter even in the case the given memory address was out of range (ANCHOR +- 2GB) -- `None` branch in code -- resulting in a wrong / misleading value being reported --- src/pool/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pool/mod.rs b/src/pool/mod.rs index 3e720860..22fc2388 100644 --- a/src/pool/mod.rs +++ b/src/pool/mod.rs @@ -359,15 +359,16 @@ impl Pool { () => { if let Some(p) = Ptr::new(p as *mut _) { self.stack.push(p); + n += 1; } } #[cfg(not(target_arch = "x86_64"))] () => { self.stack.push(unsafe { Ptr::new_unchecked(p as *mut _) }); + n += 1; } } - n += 1; p = unsafe { p.add(sz) }; len -= sz;