lib: zlib_inflate: Fix decompress function bugs

Terminate decompress function when inflateInit2() failed.
And remove the unnecessary codes.

Change-Id: I82b0c483a79e1246ff7deaceadfd3b554e9430cd
diff --git a/lib/zlib_inflate/decompress.c b/lib/zlib_inflate/decompress.c
index 692ccfa..4a7ccc3 100644
--- a/lib/zlib_inflate/decompress.c
+++ b/lib/zlib_inflate/decompress.c
@@ -103,7 +103,7 @@
 	if (in_buf[3] & 0x8) {
 		for (i = 0; i < GZIP_FILENAME_LIMIT && *stream->next_in++; i++) {
 			if (stream->avail_in == 0) {
-				dprintf(INFO, "header error");
+				dprintf(INFO, "header error\n");
 				goto gunzip_end;
 			}
 			--stream->avail_in;
@@ -111,21 +111,18 @@
 	}
 
 	rc = inflateInit2(stream, -MAX_WBITS);
+	if (rc != Z_OK) {
+		dprintf(INFO, "inflateInit2 failed!\n");
+		goto gunzip_end;
+	}
 
-	if (rc == Z_OK) {
-		if (stream->avail_in == 0) {
-			stream->next_in = in_buf;
-			stream->avail_in = out_buf_len;
-		}
-		rc = inflate(stream, 0);
-
-		/* Z_STREAM_END is "we unpacked it all" */
-		if (rc == Z_STREAM_END) {
-			rc = 0;
-		} else if (rc != Z_OK) {
-			dprintf(INFO, "uncompression error");
-			rc = -1;
-		}
+	rc = inflate(stream, 0);
+	/* Z_STREAM_END is "we unpacked it all" */
+	if (rc == Z_STREAM_END) {
+		rc = 0;
+	} else if (rc != Z_OK) {
+		dprintf(INFO, "uncompression error \n");
+		rc = -1;
 	}
 
 	inflateEnd(stream);