aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2017-04-20 13:57:05 +1000
committerSteve Bennett <steveb@workware.net.au>2017-04-20 13:57:05 +1000
commitf70a68adacf612988a3c3e0045017c262248dbd0 (patch)
treef924e68280609bce2b35709bad6264c818094ef1
parent61b7b58dcb8f49ece6c3e4c1025464aec1035e0c (diff)
downloadjimtcl-f70a68adacf612988a3c3e0045017c262248dbd0.zip
jimtcl-f70a68adacf612988a3c3e0045017c262248dbd0.tar.gz
jimtcl-f70a68adacf612988a3c3e0045017c262248dbd0.tar.bz2
zlib: compression may need some additional free space
Signed-off-by: Stuart Cassoff <stwo@bell.net>
-rw-r--r--jim-zlib.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/jim-zlib.c b/jim-zlib.c
index 36bb02f..bb91913 100644
--- a/jim-zlib.c
+++ b/jim-zlib.c
@@ -85,6 +85,10 @@ static int Jim_Compress(Jim_Interp *interp, const char *in, int len, long level,
}
strm.avail_out = deflateBound(&strm, (uLong)len);
+
+ /* Some compression methods may need a little more space */
+ strm.avail_out += 100;
+
if (strm.avail_out > INT_MAX) {
deflateEnd(&strm);
return JIM_ERR;
@@ -100,6 +104,7 @@ static int Jim_Compress(Jim_Interp *interp, const char *in, int len, long level,
if (deflate(&strm, Z_FINISH) != Z_STREAM_END) {
Jim_Free(buf);
deflateEnd(&strm);
+ Jim_SetResultString(interp, "not enough output space", -1);
return JIM_ERR;
}
@@ -107,6 +112,7 @@ static int Jim_Compress(Jim_Interp *interp, const char *in, int len, long level,
if (strm.total_out > INT_MAX) {
Jim_Free(buf);
+ Jim_SetResultString(interp, "too much output", -1);
return JIM_ERR;
}