Washi1337 / AvaloniaHex

A hex editor control for Avalonia.
MIT License
78 stars 7 forks source link

Out of Range in ByteArrayBinaryDocument #8

Closed Ploaj closed 1 week ago

Ploaj commented 2 weeks ago

https://github.com/Washi1337/AvaloniaHex/blob/ed3631074c288ecc8f36c68acc9623a19af20b04/src/AvaloniaHex/Document/ByteArrayBinaryDocument.cs#L57

If the offset >= Length, which can occur by clicking after the end of a document, an out of range exception will occur.

Washi1337 commented 2 weeks ago

I cannot seem to reproduce this problem by clicking after the end of a document in the example application. Could you specify the exact steps and OS environment you're running on?

Ploaj commented 2 weeks ago

https://github.com/user-attachments/assets/05788a34-9fc2-44de-8bea-b97a7e61846f

Windows 11

  1. Run example
  2. Scroll to bottom of document
  3. Click on area after bytes end image
  4. Type a value

Hope that explains it well enough!

Washi1337 commented 2 weeks ago

This is not a bug of ByteArrayBinaryDocument but of the hex editor not calling IBinaryDocument.ReadBytes properly.

Potential fix is in #9, if you could verify this solves the problem for you, that would be great.