In r60852 various 'unneeded' SeekI(0) calls were removed. Examined the changes in that revision and restored all SeekI(0) calls after finding out their removal caused problems with reading more than one image from ICO and ANI files. The image handling code for these formats expects to read from the start of a stream for reading its images (as well as for DoCanRead and DoGetImageCount), regardless of the index of the requested image.
Closes #12861.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67671
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
wxInt32 anih32;
memcpy( &anih32, "anih", 4 );
wxInt32 anih32;
memcpy( &anih32, "anih", 4 );
+ if ( stream.SeekI(0) == wxInvalidOffset )
+ {
+ return false;
+ }
+
if ( !stream.Read(&FCC1, 4) )
return false;
if ( !stream.Read(&FCC1, 4) )
return false;
wxInt32 seq32;
memcpy( &seq32, "seq ", 4 );
wxInt32 seq32;
memcpy( &seq32, "seq ", 4 );
+ if ( stream.SeekI(0) == wxInvalidOffset)
+ {
+ return false;
+ }
+
if ( !stream.Read(&FCC1, 4) )
return false;
if ( FCC1 != riff32 )
if ( !stream.Read(&FCC1, 4) )
return false;
if ( FCC1 != riff32 )
bool wxICOHandler::LoadFile(wxImage *image, wxInputStream& stream,
bool verbose, int index)
{
bool wxICOHandler::LoadFile(wxImage *image, wxInputStream& stream,
bool verbose, int index)
{
+ if (stream.SeekI(0) == wxInvalidOffset)
+ {
+ return false;
+ }
+
return DoLoadFile(image, stream, verbose, index);
}
return DoLoadFile(image, stream, verbose, index);
}
int wxICOHandler::DoGetImageCount(wxInputStream& stream)
{
int wxICOHandler::DoGetImageCount(wxInputStream& stream)
{
+ // It's ok to modify the stream position in this function.
+
+ if (stream.SeekI(0) == wxInvalidOffset)
+ {
+ return 0;
+ }
+
ICONDIR IconDir;
if (stream.Read(&IconDir, sizeof(IconDir)).LastRead() != sizeof(IconDir))
ICONDIR IconDir;
if (stream.Read(&IconDir, sizeof(IconDir)).LastRead() != sizeof(IconDir))
- // it's ok to modify the stream position here
return 0;
return (int)wxUINT16_SWAP_ON_BE(IconDir.idCount);
return 0;
return (int)wxUINT16_SWAP_ON_BE(IconDir.idCount);
static bool CanReadICOOrCUR(wxInputStream *stream, wxUint16 resourceType)
{
static bool CanReadICOOrCUR(wxInputStream *stream, wxUint16 resourceType)
{
+ // It's ok to modify the stream position in this function.
+
+ if ( stream->SeekI(0) == wxInvalidOffset)
+ {
+ return false;
+ }
+
- if ( !stream->Read(&iconDir, sizeof(iconDir)) ) // it's ok to modify the stream position here
+ if ( !stream->Read(&iconDir, sizeof(iconDir)) )