From afd9566ae8244335b4dff3b51985ac59b9d2966c Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 7 Mar 2018 15:49:48 +0100 Subject: [PATCH] Fixed: Don't crash when a PNG is truncated --HG-- branch : develop --- code/nel/src/misc/bitmap_png.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/code/nel/src/misc/bitmap_png.cpp b/code/nel/src/misc/bitmap_png.cpp index 251fd5495..2e700787c 100644 --- a/code/nel/src/misc/bitmap_png.cpp +++ b/code/nel/src/misc/bitmap_png.cpp @@ -37,8 +37,16 @@ namespace NLMISC static void readPNGData(png_structp png_ptr, png_bytep data, png_size_t length) { IStream *stream = static_cast(png_get_io_ptr(png_ptr)); - if (stream) - stream->serialBuffer((uint8*)data, (uint)length); + + try + { + if (stream) + stream->serialBuffer((uint8*)data, (uint)length); + } + catch (...) + { + png_error(png_ptr, "Read error while decoding PNG file"); + } } static void writePNGData(png_structp png_ptr, png_bytep data, png_size_t length)