]> git.cworth.org Git - apitrace/commitdiff
Fix a nasty crash.
authorZack Rusin <zack@kde.org>
Mon, 29 Aug 2011 21:24:44 +0000 (17:24 -0400)
committerZack Rusin <zack@kde.org>
Mon, 29 Aug 2011 21:24:44 +0000 (17:24 -0400)
the size of the compressed buffer can be under certain circumstances
bigger than the size of the input buffer.

trace_snappyfile.cpp

index ad0a57749a784ae7148ee056e4115c6f360980b2..5804c3bbb2dc76f9e731554329745ee56b7b53de 100644 (file)
@@ -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()