From dd9ea234f2e8802e182194bfe375079d1bdd1ccf Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 26 Oct 2005 14:08:43 +0000 Subject: [PATCH] Do a sanity check before reading. Otherwise, if trying to read a duff image file, the app can abort if you pass a specific image type, but simply show an error message if you pass wxBITMAP_TYPE_ANY. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36019 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/image.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/common/image.cpp b/src/common/image.cpp index c888353fd9..e967b8ece9 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -1554,7 +1554,13 @@ bool wxImage::LoadFile( wxInputStream& stream, long type, int index ) return false; } - return handler->LoadFile(this, stream, true/*verbose*/, index); + if (!handler->CanRead(stream)) + { + wxLogError(_("Image file is not of type %d."), type); + return false; + } + else + return handler->LoadFile(this, stream, true/*verbose*/, index); } bool wxImage::LoadFile( wxInputStream& stream, const wxString& mimetype, int index ) @@ -1572,7 +1578,13 @@ bool wxImage::LoadFile( wxInputStream& stream, const wxString& mimetype, int ind return false; } - return handler->LoadFile( this, stream, true/*verbose*/, index ); + if (!handler->CanRead(stream)) + { + wxLogError(_("Image file is not of type %s."), (const wxChar*) mimetype); + return false; + } + else + return handler->LoadFile( this, stream, true/*verbose*/, index ); } bool wxImage::SaveFile( wxOutputStream& stream, int type ) const -- 2.45.2