From 62cedef3ee7021ce0fc476c2a96ebc9aa0e90515 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Sun, 10 Apr 2016 15:25:28 +0100 Subject: [PATCH] Avoid undefined behavior from reading uninitialized data --- regex_macros/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regex_macros/src/lib.rs b/regex_macros/src/lib.rs index 620f7b31b9..f6ff922f4e 100644 --- a/regex_macros/src/lib.rs +++ b/regex_macros/src/lib.rs @@ -309,7 +309,7 @@ fn exec<'t>( #[inline] fn contains(&self, pc: usize) -> bool { - let s = self.sparse[pc]; + let s = unsafe { ::std::ptr::read_volatile(&self.sparse[pc]) }; s < self.size && self.dense[s].pc == pc }