summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lodepng_util.cpp6
-rw-r--r--pngdetail.cpp8
2 files changed, 10 insertions, 4 deletions
diff --git a/lodepng_util.cpp b/lodepng_util.cpp
index 9d86686..6fa1618 100644
--- a/lodepng_util.cpp
+++ b/lodepng_util.cpp
@@ -185,7 +185,7 @@ unsigned getFilterTypesInterlaced(std::vector<std::vector<unsigned char> >& filt
{
char type[5];
lodepng_chunk_type(type, chunk);
- if(std::string(type).size() != 4) return 1; //Probably not a PNG file
+ if(std::string(type).size() != 4) break; //Probably not a PNG file
if(std::string(type) == "IDAT")
{
@@ -203,11 +203,11 @@ unsigned getFilterTypesInterlaced(std::vector<std::vector<unsigned char> >& filt
}
next = lodepng_chunk_next_const(chunk);
- if (next <= chunk) return 1; // integer overflow
+ if (next <= chunk) break; // integer overflow
chunk = next;
}
- //Decompress all IDAT data
+ //Decompress all IDAT data (if the while loop ended early, this might fail)
std::vector<unsigned char> data;
error = lodepng::decompress(data, &zdata[0], zdata.size());
diff --git a/pngdetail.cpp b/pngdetail.cpp
index 00aa9dd..b11d78c 100644
--- a/pngdetail.cpp
+++ b/pngdetail.cpp
@@ -184,7 +184,13 @@ void displayChunkNames(const std::vector<unsigned char>& buffer, const Options&
std::vector<std::string> names;
std::vector<size_t> sizes;
unsigned error = lodepng::getChunkInfo(names, sizes, buffer);
- if(error) std::cout << "Error while identifying chunks. Listing identified chunks anyway." << std::endl;
+ if(error) {
+ if(!names.empty() && names.back() == "IEND" && sizes.back() == 0) {
+ std::cout << "Corruption or superfluous data detected after the IEND chunk" << std::endl;
+ } else {
+ std::cout << "Error while identifying chunks. Listing identified chunks anyway." << std::endl;
+ }
+ }
if(options.show_chunks2)
{