From 8a5b9745fb8eb40595731a86106ad784eb6b1c76 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 20 Jul 2001 01:18:08 +0000 Subject: [PATCH] fixed crash in XPM decoder when reading non XPM files git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11116 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/xpmdecod.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/xpmdecod.cpp b/src/common/xpmdecod.cpp index a0d99a11db..434e8dedf9 100644 --- a/src/common/xpmdecod.cpp +++ b/src/common/xpmdecod.cpp @@ -137,7 +137,7 @@ wxImage wxXPMDecoder::ReadFile(wxInputStream& stream) size_t i; if ( stream.Read(xpm_buffer, length).LastError() == wxSTREAM_READ_ERROR ) - return FALSE; + return wxNullImage; /* * Remove comments from the file: @@ -203,6 +203,12 @@ wxImage wxXPMDecoder::ReadFile(wxInputStream& stream) lines_cnt++; } + if ( !lines_cnt ) + { + // this doesn't really look an XPM image + return wxNullImage; + } + xpm_lines = new const char*[lines_cnt]; xpm_lines[0] = xpm_buffer; line = 1;