diff --git a/sdk/src/account.rs b/sdk/src/account.rs index f701e868ccf4e2..26355569a481f5 100644 --- a/sdk/src/account.rs +++ b/sdk/src/account.rs @@ -543,7 +543,13 @@ impl AccountSharedData { } pub fn reserve(&mut self, additional: usize) { - self.data_mut().reserve(additional) + if let Some(data) = Arc::get_mut(&mut self.data) { + data.reserve(additional) + } else { + let mut data = Vec::with_capacity(self.data.len().saturating_add(additional)); + data.extend_from_slice(&self.data); + self.data = Arc::new(data); + } } pub fn capacity(&self) -> usize {