/////////////////////////////////////////////////////////////////////////////
-// Name: imagtga.cpp
+// Name: src/common/imagtga.cpp
// Purpose: wxImage TGA handler
// Author: Seth Jackson
// CVS-ID: $Id$
index += current * pixelSize;
+ if (index >= imageSize)
+ {
+ return wxTGA_IOERR;
+ }
+
// Repeat the pixel length times.
if ( !stream.Read(buf, pixelSize) )
return wxTGA_IOERR;
index += length;
+ if (index >= imageSize)
+ {
+ return wxTGA_IOERR;
+ }
+
// Write the next length pixels directly to the image data.
if ( !stream.Read(imageData, length) )
return wxTGA_IOERR;
image->Create(width, height);
- if (!image->Ok())
+ if (!image->IsOk())
{
return wxTGA_MEMERR;
}
unsigned char hdr[HDR_SIZE];
stream.Read(hdr, HDR_SIZE); // it's ok to modify the stream position here
- // Check wether we can read the file or not.
+ // Check whether we can read the file or not.
short colorType = hdr[HDR_COLORTYPE];
if ( colorType != wxTGA_UNMAPPED && colorType != wxTGA_MAPPED )