glob icon indicating copy to clipboard operation
glob copied to clipboard

Glob panicked because of an out-of-bounds error on the pattern

Open ClementNerma opened this issue 1 year ago • 0 comments

I tried to use a pretty basic pattern, and got the following crash (ran with RUST_BACKTRACE=1):

thread 'main' panicked at C:\Users\cleme\.cargo\registry\src\index.crates.io-6f17d22bba15001f\glob-0.3.1\src\lib.rs:218:32:
byte index 14 is out of bounds of `\\*.custom*\*`
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\panicking.rs:597
   1: core::panicking::panic_fmt
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\panicking.rs:72
   2: core::fmt::Arguments::new_v1
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\fmt\mod.rs:331
   3: core::str::slice_error_fail_rt
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\str\mod.rs:110
   4: core::str::slice_error_fail
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\str\mod.rs:87
   5: core::str::traits::impl$9::index
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\core\src\str\traits.rs:361
   6: core::str::traits::impl$4::index<core::ops::range::RangeTo<usize> >
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\core\src\str\traits.rs:61
   7: glob::glob_with
             at C:\Users\cleme\.cargo\registry\src\index.crates.io-6f17d22bba15001f\glob-0.3.1\src\lib.rs:218
   8: <a call from my own crate>

Context:

  • Glob v0.3.1
  • Windows 11 23H2 (not WSL)
  • CWD on D: drive (not C:)
  • Rust v1.74.0

EDIT: Problem doesn't appear when I use \*.custom*\* instead of \\*.custom*\* (removing one of the lead backslashes)

ClementNerma avatar Nov 27 '23 11:11 ClementNerma