kaitai-io / kaitai_struct_visualizer

Kaitai Struct: visualizer and hex viewer tool
https://rubygems.org/gems/kaitai-struct-visualizer
GNU General Public License v3.0
284 stars 25 forks source link

Crashes upon user input #20

Closed amckinlay closed 6 years ago

amckinlay commented 6 years ago

https://asciinema.org/a/MF2m6DMT5UoLNdSxo7QVnKYxp (crash occurs after pressing <enter>)

  [.] magic = Traceback (most recent call last):
    16: from /usr/local/bin/ksv:23:in `<main>'
    15: from /usr/local/bin/ksv:23:in `load'
    14: from /usr/local/lib/ruby/gems/2.5.0/gems/kaitai-struct-visualizer-0.7/bin/ksv:53:in `<top (required)>'
    13: from /usr/local/lib/ruby/gems/2.5.0/gems/kaitai-struct-visualizer-0.7/lib/kaitai/struct/visualizer/visualizer.rb:21:in `run'
    12: from /usr/local/lib/ruby/gems/2.5.0/gems/kaitai-struct-visualizer-0.7/lib/kaitai/struct/visualizer/tree.rb:39:in `run'
    11: from /usr/local/lib/ruby/gems/2.5.0/gems/kaitai-struct-visualizer-0.7/lib/kaitai/struct/visualizer/tree.rb:39:in `loop'
    10: from /usr/local/lib/ruby/gems/2.5.0/gems/kaitai-struct-visualizer-0.7/lib/kaitai/struct/visualizer/tree.rb:40:in `block in run'
     9: from /usr/local/lib/ruby/gems/2.5.0/gems/kaitai-struct-visualizer-0.7/lib/kaitai/struct/visualizer/tree.rb:165:in `redraw'
     8: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
     7: from /usr/local/lib/ruby/gems/2.5.0/gems/kaitai-struct-visualizer-0.7/lib/kaitai/struct/visualizer/tree.rb:168:in `block in redraw'
     6: from /usr/local/lib/ruby/gems/2.5.0/gems/kaitai-struct-visualizer-0.7/lib/kaitai/struct/visualizer/tree.rb:196:in `draw_rec'
     5: from /usr/local/lib/ruby/gems/2.5.0/gems/kaitai-struct-visualizer-0.7/lib/kaitai/struct/visualizer/tree.rb:196:in `each'
     4: from /usr/local/lib/ruby/gems/2.5.0/gems/kaitai-struct-visualizer-0.7/lib/kaitai/struct/visualizer/tree.rb:197:in `block in draw_rec'
     3: from /usr/local/lib/ruby/gems/2.5.0/gems/kaitai-struct-visualizer-0.7/lib/kaitai/struct/visualizer/tree.rb:188:in `draw_rec'
     2: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
     1: from /usr/local/lib/ruby/gems/2.5.0/gems/kaitai-struct-visualizer-0.7/lib/kaitai/struct/visualizer/tree.rb:190:in `block in draw_rec'
/usr/local/lib/ruby/gems/2.5.0/gems/kaitai-struct-visualizer-0.7/lib/kaitai/struct/visualizer/node.rb:114:in `draw': undefined method `+' for nil:NilClass (NoMethodError)
▶ ruby --version
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]

~
▶ ksv --version
kaitai-struct-visualizer 0.7

~
▶ kaitai-struct-compiler --version
kaitai-struct-compiler 0.8
GreyCat commented 6 years ago

Hmm, that's really weird. It looks like the screen width is so small that it tries to truncate the string for display purposes beyond 0. I've applied a fix to mitigate the crash, but generally it won't help much, as it would be still unusable on such a narrow screen.

Could you check out if the crash reproduces after this fix?

amckinlay commented 6 years ago

@GreyCat Fix works.

GreyCat commented 6 years ago

Thanks!