We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c300b3e commit 3fccd37Copy full SHA for 3fccd37
regex-automata/src/util/search.rs
@@ -1971,4 +1971,23 @@ mod tests {
1971
let expected_size = 3 * core::mem::size_of::<usize>();
1972
assert_eq!(expected_size, core::mem::size_of::<MatchErrorKind>());
1973
}
1974
+
1975
+ #[test]
1976
+ fn malicious_asref_guard() {
1977
+ struct Bad(std::cell::Cell<bool>);
1978
1979
+ impl AsRef<[u8]> for Bad {
1980
+ fn as_ref(&self) -> &[u8] {
1981
+ if self.0.replace(false) {
1982
+ &[]
1983
+ } else {
1984
+ &[0; 1000]
1985
+ }
1986
1987
1988
1989
+ let bad = Bad(std::cell::Cell::new(true));
1990
+ let input = Input::new(&bad);
1991
+ assert!(input.end() <= input.haystack().len());
1992
1993
0 commit comments