resolve merge conflicts of 490fad6
to nyc-dev-plus-aosp
Change-Id: I299fe15977c1a59d0c784728872c3a7f63c95e56
This commit is contained in:
commit
38afad46d8
1 changed files with 63 additions and 54 deletions
|
@ -152,6 +152,10 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size,
|
|||
size_t bonus_size = (i == 1 && bonus_data != NULL) ? bonus_data->size : 0;
|
||||
|
||||
std::vector<unsigned char> expanded_source(expanded_len);
|
||||
|
||||
// inflate() doesn't like strm.next_out being a nullptr even with
|
||||
// avail_out being zero (Z_STREAM_ERROR).
|
||||
if (expanded_len != 0) {
|
||||
z_stream strm;
|
||||
strm.zalloc = Z_NULL;
|
||||
strm.zfree = Z_NULL;
|
||||
|
@ -187,6 +191,7 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size,
|
|||
memcpy(expanded_source.data() + (expanded_len - bonus_size),
|
||||
bonus_data->data, bonus_size);
|
||||
}
|
||||
}
|
||||
|
||||
// Next, apply the bsdiff patch (in memory) to the uncompressed
|
||||
// data.
|
||||
|
@ -209,15 +214,18 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size,
|
|||
if (expanded_source.size() < 32768U) {
|
||||
expanded_source.resize(32768U);
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<unsigned char>& temp_data = expanded_source;
|
||||
|
||||
// now the deflate stream
|
||||
z_stream strm;
|
||||
strm.zalloc = Z_NULL;
|
||||
strm.zfree = Z_NULL;
|
||||
strm.opaque = Z_NULL;
|
||||
strm.avail_in = uncompressed_target_data.size();
|
||||
strm.next_in = uncompressed_target_data.data();
|
||||
ret = deflateInit2(&strm, level, method, windowBits, memLevel, strategy);
|
||||
int ret = deflateInit2(&strm, level, method, windowBits, memLevel, strategy);
|
||||
if (ret != Z_OK) {
|
||||
printf("failed to init uncompressed data deflation: %d\n", ret);
|
||||
return -1;
|
||||
|
@ -236,6 +244,7 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size,
|
|||
if (ctx) SHA1_Update(ctx, temp_data.data(), have);
|
||||
} while (ret != Z_STREAM_END);
|
||||
deflateEnd(&strm);
|
||||
}
|
||||
} else {
|
||||
printf("patch chunk %d is unknown type %d\n", i, type);
|
||||
return -1;
|
||||
|
|
Loading…
Reference in a new issue