summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-12-01 18:36:08 +0100
committerandroid-build-merger <android-build-merger@google.com>2016-12-01 18:36:08 +0100
commit65383535a78b301765854029de6932e26bd7c365 (patch)
treedba0563a32fe2b03737c18ec2ea8733264b92a0c
parentMerge "bootable/recovery: cleanup compiler warnings (potential leak of memory)" am: d255b661a1 am: be54feda58 (diff)
parentMerge "bootable/recovery: cleanup compiler warnings (unused value)" am: ef3bea15b8 (diff)
downloadandroid_bootable_recovery-65383535a78b301765854029de6932e26bd7c365.tar
android_bootable_recovery-65383535a78b301765854029de6932e26bd7c365.tar.gz
android_bootable_recovery-65383535a78b301765854029de6932e26bd7c365.tar.bz2
android_bootable_recovery-65383535a78b301765854029de6932e26bd7c365.tar.lz
android_bootable_recovery-65383535a78b301765854029de6932e26bd7c365.tar.xz
android_bootable_recovery-65383535a78b301765854029de6932e26bd7c365.tar.zst
android_bootable_recovery-65383535a78b301765854029de6932e26bd7c365.zip
-rw-r--r--applypatch/imgdiff.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/applypatch/imgdiff.cpp b/applypatch/imgdiff.cpp
index 4dc481093..528daf113 100644
--- a/applypatch/imgdiff.cpp
+++ b/applypatch/imgdiff.cpp
@@ -321,6 +321,10 @@ unsigned char* ReadZip(const char* filename,
// -15 means we are decoding a 'raw' deflate stream; zlib will
// not expect zlib headers.
int ret = inflateInit2(&strm, -15);
+ if (ret < 0) {
+ printf("failed to initialize inflate: %d\n", ret);
+ return NULL;
+ }
strm.avail_out = curr->len;
strm.next_out = curr->data;
@@ -446,6 +450,10 @@ unsigned char* ReadImage(const char* filename,
// -15 means we are decoding a 'raw' deflate stream; zlib will
// not expect zlib headers.
int ret = inflateInit2(&strm, -15);
+ if (ret < 0) {
+ printf("failed to initialize inflate: %d\n", ret);
+ return NULL;
+ }
do {
strm.avail_out = allocated - curr->len;
@@ -553,10 +561,18 @@ int TryReconstruction(ImageChunk* chunk, unsigned char* out) {
int ret;
ret = deflateInit2(&strm, chunk->level, chunk->method, chunk->windowBits,
chunk->memLevel, chunk->strategy);
+ if (ret < 0) {
+ printf("failed to initialize deflate: %d\n", ret);
+ return -1;
+ }
do {
strm.avail_out = BUFFER_SIZE;
strm.next_out = out;
ret = deflate(&strm, Z_FINISH);
+ if (ret < 0) {
+ printf("failed to deflate: %d\n", ret);
+ return -1;
+ }
size_t have = BUFFER_SIZE - strm.avail_out;
if (memcmp(out, chunk->deflate_data+p, have) != 0) {