aboutsummaryrefslogtreecommitdiff
blob: d6cd5264ed7dfac3e7b43e67985bbf5380d1d5d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Description: fix compatibility with zlib 1.2.9 and newer
Author: Marc Deslauriers <marc.deslauriers@canonical.com>
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/clamav/+bug/1692073

--- a/libclamav/bytecode_api.c	2017-08-08 15:20:06.651685637 -0400
+++ b/libclamav/bytecode_api.c	2017-08-15 15:45:14.645714766 -0400
@@ -811,8 +811,20 @@ int32_t cli_bcapi_inflate_init(struct cl
         cli_dbgmsg("bytecode api: inflate_init: invalid buffers!\n");
         return -1;
     }
-    memset(&stream, 0, sizeof(stream));
-    ret = inflateInit2(&stream, windowBits);
+
+    b = cli_realloc(ctx->inflates, sizeof(*ctx->inflates)*n);
+    if (!b) {
+        return -1;
+    }
+    ctx->inflates = b;
+    ctx->ninflates = n;
+    b = &b[n-1];
+
+    b->from = from;
+    b->to = to;
+    b->needSync = 0;
+    memset(&b->stream, 0, sizeof(stream));
+    ret = inflateInit2(&b->stream, windowBits);
     switch (ret) {
         case Z_MEM_ERROR:
             cli_dbgmsg("bytecode api: inflateInit2: out of memory!\n");
@@ -829,20 +841,6 @@ int32_t cli_bcapi_inflate_init(struct cl
             cli_dbgmsg("bytecode api: inflateInit2: unknown error %d\n", ret);
             return -1;
     }
-
-    b = cli_realloc(ctx->inflates, sizeof(*ctx->inflates)*n);
-    if (!b) {
-        inflateEnd(&stream);
-        return -1;
-    }
-    ctx->inflates = b;
-    ctx->ninflates = n;
-    b = &b[n-1];
-
-    b->from = from;
-    b->to = to;
-    b->needSync = 0;
-    memcpy(&b->stream, &stream, sizeof(stream));
     return n-1;
 }