Merge "Fix segmentation fault with certain files." am: 56b320c00e am: a07149c664

am: 873c1e9c31

* commit '873c1e9c31edc55217d50d08014447b87398b0a4':
  Fix segmentation fault with certain files.

Change-Id: Ie5cd114670bb2b20e91c7bc0ac566dae963192ee
This commit is contained in:
Sen Jiang authored and android-build-merger committed 2016-05-07 00:51:50 +00:00
commit a8b982d4df
1 file changed
+6 -1
+6 -1
View File
@@ -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) &&