From 50ddcbb2f5004da5b2d805c079e7c9699b6b7bea Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 20 Oct 2019 12:06:03 +0200 Subject: also check the iterator is not too long --- src/librustc/lib.rs | 1 + src/librustc/mir/interpret/allocation.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 8943fc342c0..3b0ac9ada8f 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -43,6 +43,7 @@ #![feature(nll)] #![feature(non_exhaustive)] #![feature(optin_builtin_traits)] +#![feature(option_expect_none)] #![feature(range_is_empty)] #![feature(slice_patterns)] #![feature(specialization)] diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index 3bcde8defdf..87e9b91a86c 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -356,6 +356,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra> Allocation { for dest in bytes { *dest = src.next().expect("iterator was shorter than it said it would be"); } + src.next().expect_none("iterator was longer than it said it would be"); Ok(()) } -- cgit 1.4.1-3-g733a5