From 51fade4dcdd16dd03e5fc28e5a63cb5f8a95aa28 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 29 Aug 2011 17:24:44 -0400 Subject: [PATCH] Fix a nasty crash. the size of the compressed buffer can be under certain circumstances bigger than the size of the input buffer. --- trace_snappyfile.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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() -- 2.45.2