File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 1+ #![ deny( unsafe_code) ]
12#![ deny( clippy:: dbg_macro) ]
23
34#[ cfg( not( any( feature = "bat-printer" , feature = "syntect-printer" ) ) ) ]
Original file line number Diff line number Diff line change @@ -348,7 +348,14 @@ impl<'main> Config<'main> {
348348 fn build_searcher ( & self ) -> Result < Searcher > {
349349 let mut builder = SearcherBuilder :: new ( ) ;
350350 let mmap = if self . mmap {
351- unsafe { MmapChoice :: auto ( ) }
351+ // Safety: It is not possible to guarantee this configuration is safe on all platforms. However the worst
352+ // case caused by this configuration is SIGBUS (the mapped file is truncated while reading) and it just
353+ // makes hgrep abort.
354+ // See: https://docs.rs/grep-searcher/latest/grep_searcher/struct.MmapChoice.html#method.auto
355+ #[ allow( unsafe_code) ]
356+ unsafe {
357+ MmapChoice :: auto ( )
358+ }
352359 } else {
353360 MmapChoice :: never ( )
354361 } ;
You can’t perform that action at this time.
0 commit comments