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;