diff options
Diffstat (limited to 'vendor/semver/src')
-rw-r--r-- | vendor/semver/src/backport.rs | 9 | ||||
-rw-r--r-- | vendor/semver/src/identifier.rs | 8 | ||||
-rw-r--r-- | vendor/semver/src/lib.rs | 2 |
3 files changed, 17 insertions, 2 deletions
diff --git a/vendor/semver/src/backport.rs b/vendor/semver/src/backport.rs index c7751b29f..4b67f56a5 100644 --- a/vendor/semver/src/backport.rs +++ b/vendor/semver/src/backport.rs @@ -22,7 +22,9 @@ pub(crate) mod alloc { pub mod alloc { use std::mem; + use std::process; + #[derive(Copy, Clone)] pub struct Layout { size: usize, } @@ -47,5 +49,12 @@ pub(crate) mod alloc { let len_u16 = (layout.size + 1) / 2; unsafe { Vec::from_raw_parts(ptr as *mut u16, 0, len_u16) }; } + + pub fn handle_alloc_error(_layout: Layout) -> ! { + // This is unreachable because the alloc implementation above never + // returns null; Vec::reserve_exact would already have called std's + // internal handle_alloc_error. + process::abort(); + } } } diff --git a/vendor/semver/src/identifier.rs b/vendor/semver/src/identifier.rs index 170a4e05e..fbe1df020 100644 --- a/vendor/semver/src/identifier.rs +++ b/vendor/semver/src/identifier.rs @@ -66,7 +66,7 @@ // repr, leaving it available as a niche for downstream code. For example this // allows size_of::<Version>() == size_of::<Option<Version>>(). -use crate::alloc::alloc::{alloc, dealloc, Layout}; +use crate::alloc::alloc::{alloc, dealloc, handle_alloc_error, Layout}; use core::mem; use core::num::{NonZeroU64, NonZeroUsize}; use core::ptr::{self, NonNull}; @@ -123,6 +123,9 @@ impl Identifier { let layout = unsafe { Layout::from_size_align_unchecked(size, align) }; // SAFETY: layout's size is nonzero. let ptr = unsafe { alloc(layout) }; + if ptr.is_null() { + handle_alloc_error(layout); + } let mut write = ptr; let mut varint_remaining = len; while varint_remaining > 0 { @@ -203,6 +206,9 @@ impl Clone for Identifier { let layout = unsafe { Layout::from_size_align_unchecked(size, align) }; // SAFETY: layout's size is nonzero. let clone = unsafe { alloc(layout) }; + if clone.is_null() { + handle_alloc_error(layout); + } // SAFETY: new allocation cannot overlap the previous one (this was // not a realloc). The argument ptrs are readable/writeable // respectively for size bytes. diff --git a/vendor/semver/src/lib.rs b/vendor/semver/src/lib.rs index 5185b752d..ca4d1119c 100644 --- a/vendor/semver/src/lib.rs +++ b/vendor/semver/src/lib.rs @@ -60,7 +60,7 @@ //! //! [Specifying Dependencies]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html -#![doc(html_root_url = "https://docs.rs/semver/1.0.12")] +#![doc(html_root_url = "https://docs.rs/semver/1.0.14")] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![cfg_attr(all(not(feature = "std"), not(no_alloc_crate)), no_std)] #![cfg_attr(not(no_unsafe_op_in_unsafe_fn_lint), deny(unsafe_op_in_unsafe_fn))] |