瀏覽代碼

HPCC-16346 Improve zlib compression output buffer size calculation

Buffer only needs to be 0.1% larger than input +12 bytes, was larger.

Signed-off-by: Anthony Fishbeck <anthony.fishbeck@lexisnexis.com>
Anthony Fishbeck 8 年之前
父節點
當前提交
70e7304047
共有 2 個文件被更改,包括 1 次插入2 次删除
  1. 0 1
      common/thorhelper/roxiehelper.cpp
  2. 1 1
      system/security/zcrypt/zcrypt.cpp

+ 0 - 1
common/thorhelper/roxiehelper.cpp

@@ -2741,7 +2741,6 @@ void HttpHelper::parseRequestHeaders(const char *headers)
     val = queryRequestHeader("Authorization");
     if (val && !strncmp(val, "Basic ", 6))
         setAuthToken(val+6);
-
 }
 
 void HttpHelper::parseURL()

+ 1 - 1
system/security/zcrypt/zcrypt.cpp

@@ -1108,7 +1108,7 @@ void zlib_deflate(MemoryBuffer &mb, const char* inputBuffer, unsigned int inputS
 
     // Create output memory buffer for compressed data. The zlib documentation states that
     // destination buffer size must be at least 0.1% larger than avail_in plus 12 bytes.
-    const unsigned long outsize = (unsigned long)floorf((float)inputSize * 1.01f) + 12;
+    const unsigned long outsize = (unsigned long) inputSize + inputSize / 1000 + 13;
     Bytef* outbuf = (Bytef*) mb.reserveTruncate(outsize);
 
     do