Include upstream patch to avoid dropping uninitialized memory in some cases

epel10
Fabio Valentini 9 months ago
parent 461462dcb3
commit f1242022c7
No known key found for this signature in database
GPG Key ID: 5AC5F572E5D410AF

@ -0,0 +1,36 @@
From 1fa1dcca990d4e9d112f154c83802167f69f4fe9 Mon Sep 17 00:00:00 2001
From: Amanieu d'Antras <amanieu@gmail.com>
Date: Mon, 4 Mar 2024 17:38:02 +0000
Subject: [PATCH] Fix index calculation in panic guard of clone_from_impl
Previously, it was possible for an uninitialized element to be dropped
if all of the following occurred:
- `clone_from` was called where `T: !Copy`.
- The `clone` implementation of `T` panicked.
- The first bucket of the source `HashMap` contained an entry.
---
src/raw/mod.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/raw/mod.rs b/src/raw/mod.rs
index ddd4fe7c1..22c01f5e9 100644
--- a/src/raw/mod.rs
+++ b/src/raw/mod.rs
@@ -3582,7 +3582,7 @@ impl<T: Clone, A: Allocator + Clone> RawTable<T, A> {
// cloned so far.
let mut guard = guard((0, &mut *self), |(index, self_)| {
if T::NEEDS_DROP {
- for i in 0..=*index {
+ for i in 0..*index {
if self_.is_bucket_full(i) {
self_.bucket(i).drop();
}
@@ -3596,7 +3596,7 @@ impl<T: Clone, A: Allocator + Clone> RawTable<T, A> {
to.write(from.as_ref().clone());
// Update the index in case we need to unwind.
- guard.0 = index;
+ guard.0 = index + 1;
}
// Successfully cloned all items, no need to clean up.

@ -13,6 +13,9 @@ License: MIT OR Apache-2.0
URL: https://crates.io/crates/hashbrown
Source: %{crates_source}
# upstream patch to avoid dropping uninitialized memory in some cases
Patch: https://github.com/rust-lang/hashbrown/commit/1fa1dcc.patch
BuildRequires: cargo-rpm-macros >= 24
%global _description %{expand:

Loading…
Cancel
Save