diff --git a/src/agent/debugger/src/breakpoint.rs b/src/agent/debugger/src/breakpoint.rs index 71cffa997..3182b7290 100644 --- a/src/agent/debugger/src/breakpoint.rs +++ b/src/agent/debugger/src/breakpoint.rs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#![allow(clippy::uninit_vec)] - use std::{ collections::{btree_map::Range, BTreeMap}, ops::RangeBounds, @@ -269,10 +267,16 @@ impl BreakpointCollection { fn bulk_read_process_memory(&self, process_handle: HANDLE) -> Result> { let mut buffer: Vec = Vec::with_capacity(self.bulk_region_size()); + process::read_memory_array( + process_handle, + self.min_breakpoint_addr as _, + buffer.spare_capacity_mut(), + )?; + unsafe { buffer.set_len(self.bulk_region_size()); } - process::read_memory_array(process_handle, self.min_breakpoint_addr as _, &mut buffer)?; + Ok(buffer) } diff --git a/src/agent/win-util/src/process.rs b/src/agent/win-util/src/process.rs index fa95df13d..551840277 100644 --- a/src/agent/win-util/src/process.rs +++ b/src/agent/win-util/src/process.rs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#![allow(clippy::uninit_vec)] - use std::{ ffi::OsString, mem::{size_of, MaybeUninit}, @@ -112,10 +110,10 @@ pub fn read_narrow_string( len: usize, ) -> Result { let mut buf: Vec = Vec::with_capacity(len); + read_memory_array(process_handle, remote_address, buf.spare_capacity_mut())?; unsafe { buf.set_len(len); } - read_memory_array::(process_handle, remote_address, &mut buf[..])?; Ok(String::from_utf8_lossy(&buf).into()) } @@ -125,10 +123,10 @@ pub fn read_wide_string( len: usize, ) -> Result { let mut buf: Vec = Vec::with_capacity(len); + read_memory_array(process_handle, remote_address, buf.spare_capacity_mut())?; unsafe { buf.set_len(len); } - read_memory_array::(process_handle, remote_address, &mut buf[..])?; Ok(OsString::from_wide(&buf)) }