From 061bda7aaa0cdcf48d34286da3203a79744d4137 Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 8 Dec 2019 07:46:29 +0000 Subject: [PATCH] Core: GZCompress fixes (thanks zsolt) git-svn-id: svn://ultimatepp.org/upp/trunk@13743 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/z.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/uppsrc/Core/z.cpp b/uppsrc/Core/z.cpp index 24db8ecb1..73f058221 100644 --- a/uppsrc/Core/z.cpp +++ b/uppsrc/Core/z.cpp @@ -427,7 +427,7 @@ bool GZCompressFile(const char *dstfile, const char *srcfile, Gate FileOut out(dstfile); if(!out) return false; - if(GZCompress(out, in, (int)in.GetLeft(), progress) < 0) + if(GZCompress(out, in, in.GetLeft(), progress) < 0) return false; out.Close(); return !out.IsError(); @@ -446,7 +446,7 @@ bool GZDecompressFile(const char *dstfile, const char *srcfile, Gateprogress) Gate AsGate64(Gate gate) { Gate h; - h << [=](int64 a, int64 b) { return gate((int)a, (int)b); }; + h << [=](int64 a, int64 b) { + if(b > ((int64)INT_MAX << 10)) + return gate((int)(a>>32), (int)(b>>32)); + if(b > INT_MAX) + return gate((int)(a>>22), (int)(b>>22)); + return gate((int)a, (int)b); + }; return h; }