From b31327bbdbdd8488c9321ac3d6adf3a0fc4388c4 Mon Sep 17 00:00:00 2001 From: Carsten Teibes Date: Fri, 27 May 2016 19:30:57 +0200 Subject: [PATCH] Do not crash on broken images. Related: #858,#432 This makes it also possible to degrades most image reader errors to warnings, because Player can go on if one image is not useable. --- src/bitmap.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bitmap.cpp b/src/bitmap.cpp index e4fd389b07..0fa412e411 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -552,12 +552,13 @@ Bitmap::Bitmap(const std::string& filename, bool transparent, uint32_t flags) { ImagePNG::ReadPNG(stream, (void*)NULL, transparent, w, h, pixels); else #endif - Output::Error("Unsupported image file %s", filename.c_str()); + Output::Warning("Unsupported image file %s", filename.c_str()); fclose(stream); Init(w, h, (void *) NULL); - ConvertImage(w, h, pixels, transparent); + if (pixels) + ConvertImage(w, h, pixels, transparent); CheckPixels(flags); } @@ -586,10 +587,11 @@ Bitmap::Bitmap(const uint8_t* data, unsigned bytes, bool transparent, uint32_t f ImagePNG::ReadPNG((FILE*) NULL, (const void*) data, transparent, w, h, pixels); else #endif - Output::Error("Unsupported image"); + Output::Warning("Unsupported image"); Init(w, h, (void *) NULL); - ConvertImage(w, h, pixels, transparent); + if (pixels) + ConvertImage(w, h, pixels, transparent); CheckPixels(flags); }