about summary refs log tree commit diff
path: root/library/std/src/io/tests.rs
diff options
context:
space:
mode:
authorjoboet <jonasboettiger@icloud.com>2024-04-11 18:33:46 +0200
committerjoboet <jonasboettiger@icloud.com>2024-04-11 18:33:46 +0200
commit91fe6f9343a384dd7d598705a4bc4b137845dbea (patch)
treee65298f756ad920b255ab344c0ba6fbf48344d4a /library/std/src/io/tests.rs
parent05ccc49a4412a23a7afa1226804bb44558fb15b0 (diff)
downloadrust-91fe6f9343a384dd7d598705a4bc4b137845dbea.tar.gz
rust-91fe6f9343a384dd7d598705a4bc4b137845dbea.zip
core: panic on overflow in `BorrowedCursor`
Diffstat (limited to 'library/std/src/io/tests.rs')
-rw-r--r--library/std/src/io/tests.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/library/std/src/io/tests.rs b/library/std/src/io/tests.rs
index eb5d5988768..090a091b09a 100644
--- a/library/std/src/io/tests.rs
+++ b/library/std/src/io/tests.rs
@@ -210,6 +210,15 @@ fn read_buf_exact() {
 }
 
 #[test]
+#[should_panic]
+fn borrowed_cursor_advance_overflow() {
+    let mut buf = [0; 512];
+    let mut buf = BorrowedBuf::from(&mut buf[..]);
+    buf.unfilled().advance(1);
+    buf.unfilled().advance(usize::MAX);
+}
+
+#[test]
 fn take_eof() {
     struct R;