bsdiff icon indicating copy to clipboard operation
bsdiff copied to clipboard

Fix incorrect binary search logic which would cause the longest matching string to be missed

Open etnlgd opened this issue 2 years ago • 1 comments

When memcmp returns 0 and cmpsize < newsize, it means that old + I[x] is smaller than new, then search(..., x, en, pos) should be performed instead of search(..., st, x, pos)

etnlgd avatar Sep 06 '23 15:09 etnlgd

You can reproduce this bug by constructing the following two files:

  • old.txt: 20MB, all characters are '0' except the last two characters are '1' and '0'. It's something like this: "0000000...000010"

  • new.txt: 20MB, all characters are '0'

bsdiff old.txt new.txt patch.out will take very very long time

etnlgd avatar Sep 06 '23 15:09 etnlgd