diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-01-18 21:48:36 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-01-18 21:48:36 +0000 |
commit | 80c89a0bd4283e8268bd9ad6e434a1079a2e2f71 (patch) | |
tree | 6ef80674e224abccd376d56c2256b2f3576330a8 | |
parent | 065be7af7bf8303ae6746863aed2c5399ea42327 (diff) |
Fix some zlib memory leaks, originally from Mark Adler
-rw-r--r-- | lib/libz/infblock.c | 9 | ||||
-rw-r--r-- | sys/lib/libz/infblock.c | 9 | ||||
-rw-r--r-- | sys/net/zlib.c | 10 |
3 files changed, 22 insertions, 6 deletions
diff --git a/lib/libz/infblock.c b/lib/libz/infblock.c index f4920faa5ea..a883a1878b9 100644 --- a/lib/libz/infblock.c +++ b/lib/libz/infblock.c @@ -249,10 +249,12 @@ int r; &s->sub.trees.tb, s->hufts, z); if (t != Z_OK) { - ZFREE(z, s->sub.trees.blens); r = t; if (r == Z_DATA_ERROR) + { + ZFREE(z, s->sub.trees.blens); s->mode = BAD; + } LEAVE } s->sub.trees.index = 0; @@ -313,11 +315,13 @@ int r; t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), s->sub.trees.blens, &bl, &bd, &tl, &td, s->hufts, z); - ZFREE(z, s->sub.trees.blens); if (t != Z_OK) { if (t == (uInt)Z_DATA_ERROR) + { + ZFREE(z, s->sub.trees.blens); s->mode = BAD; + } r = t; LEAVE } @@ -329,6 +333,7 @@ int r; } s->sub.decode.codes = c; } + ZFREE(z, s->sub.trees.blens); s->mode = CODES; case CODES: UPDATE diff --git a/sys/lib/libz/infblock.c b/sys/lib/libz/infblock.c index d3d3bb8e347..df9eb431f51 100644 --- a/sys/lib/libz/infblock.c +++ b/sys/lib/libz/infblock.c @@ -246,10 +246,12 @@ int r; &s->sub.trees.tb, s->hufts, z); if (t != Z_OK) { - ZFREE(z, s->sub.trees.blens); r = t; if (r == Z_DATA_ERROR) + { + ZFREE(z, s->sub.trees.blens); s->mode = BAD; + } LEAVE } s->sub.trees.index = 0; @@ -310,11 +312,13 @@ int r; t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), s->sub.trees.blens, &bl, &bd, &tl, &td, s->hufts, z); - ZFREE(z, s->sub.trees.blens); if (t != Z_OK) { if (t == (uInt)Z_DATA_ERROR) + { + ZFREE(z, s->sub.trees.blens); s->mode = BAD; + } r = t; LEAVE } @@ -326,6 +330,7 @@ int r; } s->sub.decode.codes = c; } + ZFREE(z, s->sub.trees.blens); s->mode = CODES; case CODES: UPDATE diff --git a/sys/net/zlib.c b/sys/net/zlib.c index 1a21e49fb74..682302a928e 100644 --- a/sys/net/zlib.c +++ b/sys/net/zlib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zlib.c,v 1.9 2001/01/29 06:12:11 mickey Exp $ */ +/* $OpenBSD: zlib.c,v 1.10 2002/01/18 21:48:35 millert Exp $ */ /* $NetBSD: zlib.c,v 1.2 1996/03/16 23:55:40 christos Exp $ */ /* @@ -3405,7 +3405,10 @@ int r; { r = t; if (r == Z_DATA_ERROR) + { + ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt)); s->mode = BADB; + } LEAVE } s->sub.trees.index = 0; @@ -3468,7 +3471,10 @@ int r; if (t != Z_OK) { if (t == (uInt)Z_DATA_ERROR) + { + ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt)); s->mode = BADB; + } r = t; LEAVE } @@ -3480,11 +3486,11 @@ int r; r = Z_MEM_ERROR; LEAVE } - ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt)); s->sub.decode.codes = c; s->sub.decode.tl = tl; s->sub.decode.td = td; } + ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt)); s->mode = CODES; case CODES: UPDATE |