diff --git a/src/history/file.rs b/src/history/file.rs index 1215f5583..0dfb63ae3 100644 --- a/src/history/file.rs +++ b/src/history/file.rs @@ -128,6 +128,12 @@ pub fn create(mut history_file: &File) -> std::io::Result { )) } }; + if len == 0 { + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + "History file is empty. Cannot create memory mapping with length 0.", + )); + } let map_anon = |mut file: &File, len: usize| -> std::io::Result { let mut region = MmapRegion::map_anon(len)?; // If we mapped anonymous memory, we have to read from the file.