jdm / libmzx

A Rust library for loading and manipulating MegaZeux worlds.
MIT License
2 stars 0 forks source link

Panic on out of bounds command #93

Closed jdm closed 3 years ago

jdm commented 3 years ago

https://www.digitalmzx.com/show.php?id=481

     Running `target/debug/capture image.png output.json unzipped/SPACESTA.MZX`
Capturing board 6: Mars
thread 'main' panicked at 'index out of bounds: the len is 10000 but the index is 13843', /Users/jdm/src/libmzx/src/lib.rs:366:10
stack backtrace:
   0: rust_begin_unwind
             at /rustc/5dc8789e300930751a78996da0fa906be5a344a2/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/5dc8789e300930751a78996da0fa906be5a344a2/library/core/src/panicking.rs:92:14
   2: core::panicking::panic_bounds_check
             at /rustc/5dc8789e300930751a78996da0fa906be5a344a2/library/core/src/panicking.rs:69:5
   3: <usize as core::slice::index::SliceIndex<[T]>>::index
             at /rustc/5dc8789e300930751a78996da0fa906be5a344a2/library/core/src/slice/index.rs:184:10
   4: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
             at /rustc/5dc8789e300930751a78996da0fa906be5a344a2/library/core/src/slice/index.rs:15:9
   5: <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index
             at /rustc/5dc8789e300930751a78996da0fa906be5a344a2/library/alloc/src/vec/mod.rs:2427:9
   6: libmzx::Board::level_at
             at /Users/jdm/src/libmzx/src/lib.rs:366:10
   7: libmzx::robot::run_one_command
             at /Users/jdm/src/libmzx/src/robot.rs:1057:60
   8: libmzx::robot::update_robot
             at /Users/jdm/src/libmzx/src/robot.rs:475:15
   9: libmzx::board::update_board
             at /Users/jdm/src/libmzx/src/board.rs:197:34
  10: capture::run
             at ./capture/src/main.rs:145:17
  11: capture::main
             at ./capture/src/main.rs:223:9
  12: core::ops::function::FnOnce::call_once
             at /rustc/5dc8789e300930751a78996da0fa906be5a344a2/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
jdm commented 3 years ago

Fixed by 615dae20f2d82a2bab6d19cb089ada5225b55d56