From: Zack Rusin <zack@kde.org>
Date: Mon, 29 Aug 2011 21:24:44 +0000 (-0400)
Subject: Fix a nasty crash.
X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=51fade4dcdd16dd03e5fc28e5a63cb5f8a95aa28;p=apitrace

Fix a nasty crash.

the size of the compressed buffer can be under certain circumstances
bigger than the size of the input buffer.
---

diff --git a/trace_snappyfile.cpp b/trace_snappyfile.cpp
index ad0a577..5804c3b 100644
--- a/trace_snappyfile.cpp
+++ b/trace_snappyfile.cpp
@@ -66,7 +66,9 @@ SnappyFile::SnappyFile(const std::string &filename,
       m_cachePtr(0),
       m_cacheSize(0)
 {
-    m_compressedCache = new char[SNAPPY_CHUNK_SIZE];
+    size_t maxCompressedLength =
+        snappy::MaxCompressedLength(SNAPPY_CHUNK_SIZE);
+    m_compressedCache = new char[maxCompressedLength];
 }
 
 SnappyFile::~SnappyFile()