From 6426a7cb6ff48bdf75eb8b625be8cb6b2b59ceb3 Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Wed, 16 Jan 2019 11:20:56 -0500 Subject: [PATCH] Fix out-of-bounds panic during deserialization; produce error instead. Fixes #522 --- src/base/array_storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/array_storage.rs b/src/base/array_storage.rs index f1a0ea13..3beab9e1 100644 --- a/src/base/array_storage.rs +++ b/src/base/array_storage.rs @@ -331,7 +331,7 @@ where let mut curr = 0; while let Some(value) = try!(visitor.next_element()) { - out[curr] = value; + *out.get_mut(curr).ok_or_else(|| V::Error::invalid_length(curr, &self))? = value; curr += 1; }