From 2bec4a63459eaf641abba568932c2d2613e8f225 Mon Sep 17 00:00:00 2001 From: JeckDev Date: Fri, 22 Jan 2016 04:59:49 -0800 Subject: Fixed crash on uncompressed PNG files. When writing an uncompressed PNG, deflateDynamic erroneously indexed a newly allocated block of datasize length using the datapos offset. This would crash anytime datapos > 0. --- lodepng.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lodepng.cpp b/lodepng.cpp index 8665292..8e6e368 100644 --- a/lodepng.cpp +++ b/lodepng.cpp @@ -1768,7 +1768,7 @@ static unsigned deflateDynamic(ucvector* out, size_t* bp, Hash* hash, else { if(!uivector_resize(&lz77_encoded, datasize)) ERROR_BREAK(83 /*alloc fail*/); - for(i = datapos; i < dataend; ++i) lz77_encoded.data[i] = data[i]; /*no LZ77, but still will be Huffman compressed*/ + for(i = datapos; i < dataend; ++i) lz77_encoded.data[i-datapos] = data[i]; /*no LZ77, but still will be Huffman compressed*/ } if(!uivector_resizev(&frequencies_ll, 286, 0)) ERROR_BREAK(83 /*alloc fail*/); -- cgit v1.2.3