title: Unzip buffer with large data length is crashing
body: <p>This is the function I am using to unzip buffer. </p>
  
  <pre><code>string unzipBuffer(size_t decryptedLength, unsigned char * decryptedData)
  {
      z_stream stream;
      stream.zalloc = Z_NULL;
      stream.zfree = Z_NULL;
      stream.avail_in = decryptedLength;
      stream.next_in = (Bytef *)decryptedData;
      stream.total_out = 0;
      stream.avail_out = 0;
      size_t dataLength = decryptedLength* 1.5;
      char c[dataLength];
  
      if (inflateInit2(&amp;stream, 47) == Z_OK)
      {
          int status = Z_OK;
          while (status == Z_OK)
          {
              if (stream.total_out &gt;= dataLength)
              {
                  dataLength += decryptedLength * 0.5;
              }
  
              stream.next_out = (Bytef *)c + stream.total_out;
  
              stream.avail_out = (uint)(dataLength - stream.total_out);
  
              status = inflate (&amp;stream, Z_SYNC_FLUSH);
  
          }
          if (inflateEnd(&amp;stream) == Z_OK)
          {
              if (status == Z_STREAM_END)
              {
                  dataLength = stream.total_out;
              }
          }
      }
      std::string decryptedContentStr(c, c + dataLength);
      return decryptedContentStr;
  }
  </code></pre>
  
  <p>And it was working fine until today when I realized that it crashes with large data buffer (Ex: decryptedLength: 342792) on this line:</p>
  
  <pre><code>status = inflate (&amp;stream, Z_SYNC_FLUSH);
  </code></pre>
  
  <p>after one or two iterations. Can anyone help me please?</p>