mirror of
https://github.com/expo/bsdiff.git
synced 2026-11-14 17:49:03 -10:00
Merge "Fix segmentation fault with certain files."
am: 56b320c00e
* commit '56b320c00e8f86732ca2927f9b4f1363e306caa8':
Fix segmentation fault with certain files.
Change-Id: Ifee04a04b1d04d2942b69c5235babff374b47164
This commit is contained in:
commit
a07149c664
1 file changed
+6
-1
@@ -62,6 +62,11 @@ static off_t matchlen(const u_char* old, off_t oldsize, const u_char* new_buf,
|
||||
return i;
|
||||
}
|
||||
|
||||
// This is a binary search of the string |new_buf| of size |newsize| (or a
|
||||
// prefix of it) in the |old| string with size |oldsize| using the suffix array
|
||||
// |I|. |st| and |en| is the start and end of the search range (inclusive).
|
||||
// Returns the length of the longest prefix found and stores the position of the
|
||||
// string found in |*pos|.
|
||||
static off_t search(saidx_t* I, const u_char* old, off_t oldsize,
|
||||
const u_char* new_buf, off_t newsize, off_t st, off_t en,
|
||||
off_t* pos) {
|
||||
@@ -206,7 +211,7 @@ int bsdiff(const u_char* old_buf, off_t oldsize, const u_char* new_buf,
|
||||
prev_pos=pos;
|
||||
|
||||
len=search(I,old_buf,oldsize,new_buf+scan,newsize-scan,
|
||||
0,oldsize,&pos);
|
||||
0,oldsize-1,&pos);
|
||||
|
||||
for(;scsc<scan+len;scsc++)
|
||||
if((scsc+lastoffset<oldsize) &&
|
||||
|
||||
Reference in new issue
Block a user