From 8313bbc30cead62dc549bd0ff70d04195c1d2e83 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 7 May 2023 22:41:18 -0400 Subject: [PATCH] uefi: Clear the Vec in DevicePathBuilder::with_vec Previously there was an implicit assumption that the `Vec` was empty; clear it to ensure this. --- CHANGELOG.md | 1 + uefi/src/proto/device_path/build.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c167a0c4..83a40d4b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ - The `Revision` struct's one field is now public. - Renamed `CStr8::to_bytes` to `CStr8::as_bytes` and changed the semantics: The trailing null character is now always included in the returned slice. +- `DevicePathBuilder::with_vec` now clears the `Vec` before use. ## uefi-macros - [Unreleased] diff --git a/uefi/src/proto/device_path/build.rs b/uefi/src/proto/device_path/build.rs index 63c731516..03e24b75e 100644 --- a/uefi/src/proto/device_path/build.rs +++ b/uefi/src/proto/device_path/build.rs @@ -83,8 +83,11 @@ impl<'a> DevicePathBuilder<'a> { } /// Create a builder backed by a `Vec`. + /// + /// The `Vec` is cleared before use. #[cfg(feature = "alloc")] pub fn with_vec(v: &'a mut Vec) -> Self { + v.clear(); Self { storage: BuilderStorage::Vec(v), }