Index: src/modules/loaders/loader_tga.c =================================================================== --- src/modules/loaders/loader_tga.c +++ src/modules/loaders/loader_tga.c 2007-09-14 09:21:16.000000000 +0200 @@ -350,7 +350,9 @@ else dataptr = im->data + (y * im->w); - for (x = 0; x < im->w; x++) /* for each pixel in the row */ + for (x = 0; x < im->w + && bufptr+bpp/8 < bufend; + x++) /* for each pixel in the row */ { switch (bpp) { @@ -412,7 +414,11 @@ curbyte = *bufptr++; count = (curbyte & 0x7F) + 1; - + if (dataptr+count > final_pixel) + { + count = final_pixel - dataptr; + } + if (curbyte & 0x80) /* RLE packet */ { int i;