From 5c98cb9b753ee6b278d333e1a98dff55a7095b44 Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Thu, 5 May 2011 23:52:07 +0000 Subject: [PATCH] Fixed failing to load ANI, BMP, and ICO images from non-seekable streams. Guarded recently added SeekI() calls by calling is IsSeekable() first. Regression since r67671. Closes #12861 (again). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67708 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/anidecod.cpp | 4 ++-- src/common/imagbmp.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/anidecod.cpp b/src/common/anidecod.cpp index 2cb075948d..d0d0b6d75b 100644 --- a/src/common/anidecod.cpp +++ b/src/common/anidecod.cpp @@ -127,7 +127,7 @@ bool wxANIDecoder::DoCanRead(wxInputStream& stream) const wxInt32 anih32; memcpy( &anih32, "anih", 4 ); - if ( stream.SeekI(0) == wxInvalidOffset ) + if ( stream.IsSeekable() && stream.SeekI(0) == wxInvalidOffset ) { return false; } @@ -225,7 +225,7 @@ bool wxANIDecoder::Load( wxInputStream& stream ) wxInt32 seq32; memcpy( &seq32, "seq ", 4 ); - if ( stream.SeekI(0) == wxInvalidOffset) + if ( stream.IsSeekable() && stream.SeekI(0) == wxInvalidOffset ) { return false; } diff --git a/src/common/imagbmp.cpp b/src/common/imagbmp.cpp index 71dd36d635..631130805c 100644 --- a/src/common/imagbmp.cpp +++ b/src/common/imagbmp.cpp @@ -1335,7 +1335,7 @@ bool wxICOHandler::SaveFile(wxImage *image, bool wxICOHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose, int index) { - if (stream.SeekI(0) == wxInvalidOffset) + if ( stream.IsSeekable() && stream.SeekI(0) == wxInvalidOffset ) { return false; } @@ -1430,7 +1430,7 @@ int wxICOHandler::DoGetImageCount(wxInputStream& stream) { // It's ok to modify the stream position in this function. - if (stream.SeekI(0) == wxInvalidOffset) + if ( stream.IsSeekable() && stream.SeekI(0) == wxInvalidOffset ) { return 0; } @@ -1505,7 +1505,7 @@ static bool CanReadICOOrCUR(wxInputStream *stream, wxUint16 resourceType) { // It's ok to modify the stream position in this function. - if ( stream->SeekI(0) == wxInvalidOffset) + if ( stream->IsSeekable() && stream->SeekI(0) == wxInvalidOffset ) { return false; } -- 2.47.2