afrantzis / bless

Bless - Gtk# Hex Editor
GNU General Public License v2.0
210 stars 38 forks source link

Bless crashes on reloading file if it becomes less in size #43

Closed ValdikSS closed 3 years ago

ValdikSS commented 3 years ago

When you edit the file in Bless and then edit the file outside of Bless, bless asks to reload or ignore the changes. When new size of the file is smaller, and all the data is selected (ctrl+a), Bless crashes on reload.

How to reproduce:

  1. echo 1234567890 > test.bin
  2. Open test.bin in Bless
  3. Press ctrl+a in Bless
  4. echo 1234 > test.bin
  5. Press reload in Bless
  6. Bless crashes
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
System.IndexOutOfRangeException: ByteBuffer[5]
  at Bless.Buffers.ByteBuffer.get_Item (System.Int64 index) [0x0004c] in <c2988b8c99eb458fa3ad609bd93e4a45>:0 
  at Bless.Buffers.ByteBuffer.RangeToByteArray (Bless.Util.IRange range) [0x0002e] in <c2988b8c99eb458fa3ad609bd93e4a45>:0 
  at Bless.Gui.Plugins.PatternHighlighter.BeforeRender (Bless.Gui.Areas.AreaGroup ag) [0x00067] in <561c6d16058249b594bef4dc188f5293>:0 
  at Bless.Gui.Areas.AreaGroup.Render (System.Boolean force) [0x0001d] in <750a4b64d25f4095b052e511c19ad2b3>:0 
  at Bless.Gui.Areas.AreaGroup.<SetChanged>m__0 (System.Object , System.EventArgs ) [0x00055] in <750a4b64d25f4095b052e511c19ad2b3>:0 
  at Gtk.Application+InvokeCB.Invoke () [0x00000] in <7aab76e87bce48a4b45cf7fa613cb70c>:0 
  at GLib.Timeout+TimeoutProxy.Invoke (System.IntPtr data) [0x00000] in <ed39f21b9e9343dcbd442a17ad356a9f>:0 
  at GLib.SourceProxy.HandlerInternal (System.IntPtr data) [0x00000] in <ed39f21b9e9343dcbd442a17ad356a9f>:0 
  at GLib.ExceptionManager.RaiseUnhandledException (System.Exception e, System.Boolean is_terminal) [0x00000] in <ed39f21b9e9343dcbd442a17ad356a9f>:0 
  at GLib.SourceProxy.HandlerInternal (System.IntPtr data) [0x00000] in <ed39f21b9e9343dcbd442a17ad356a9f>:0 
  at Gtk.Application.gtk_main () [0x00000] in <7aab76e87bce48a4b45cf7fa613cb70c>:0 
  at Gtk.Application.Run () [0x00000] in <7aab76e87bce48a4b45cf7fa613cb70c>:0 
  at BlessMain..ctor (System.String[] args) [0x00000] in <ec18755d4cac4c61aedeff7956353145>:0 
  at BlessMain.Main (System.String[] args) [0x00000] in <ec18755d4cac4c61aedeff7956353145>:0
ValdikSS commented 3 years ago

The issue is in PatternMatchHighlight plugin. Workaround: Edit→Preferences→Plugins→PatternMatchHighlight, untick "Highlight matches of selection pattern".

afrantzis commented 3 years ago

Thanks!