eerimoq / bincopy

Mangling of various file formats that conveys binary information (Motorola S-Record, Intel HEX, TI-TXT, Verilog VMEM, ELF and binary files).
MIT License
109 stars 38 forks source link

Incorrect error check condition? #28

Closed amkld closed 2 years ago

amkld commented 2 years ago

Hi I was checking the code in bincopy.py and I think the if condition used to check for non-overlapping segments in remove_data is incorrect:

if ((minimum_address >= self.maximum_address)
            and (maximum_address <= self.minimum_address)):

This will only be true in the rare case of trying to remove a zero-length segment from a zero-length segment at the same address which is not what was intended. I think the and condition should be changed to or i.e.

if ((minimum_address >= self.maximum_address)
            or (maximum_address <= self.minimum_address)):
eerimoq commented 2 years ago

You don't happen to have an example that triggers the error? It would be very helpful.

eerimoq commented 2 years ago

Fixed it and created a new version of the package, 17.10.3. Feel free to test it and let me know if it doesn't work.

amkld commented 2 years ago

You don't happen to have an example that triggers the error? It would be very helpful.

I don't actually have an example that would trigger the error in the old code. Was trying to think of a unit test when I realised it's probably a bug. Thanks for the update.