X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fpcx.c;h=7756b240f1831041170475fd12a52277043d3ee1;hb=2b29e32d0afc8b277ccf53f20ece4a28839529f5;hp=9792331422cbb919763f6d13a45eee7dc90201ed;hpb=a750ba6776fdfb711f5da2e6094c8010cd19645a;p=rocksndiamonds.git diff --git a/src/libgame/pcx.c b/src/libgame/pcx.c index 97923314..7756b240 100644 --- a/src/libgame/pcx.c +++ b/src/libgame/pcx.c @@ -122,14 +122,23 @@ static boolean PCX_ReadBitmap(FILE *file, struct PCX_Header *pcx, Image *image) if (count == 0) { if ((value_int = fgetc(file)) == EOF) + { + free(row_buffer); return FALSE; + } + value = (byte)value_int; if ((value & 0xc0) == 0xc0) /* this is a repeat count byte */ { count = value & 0x3f; /* extract repeat count from byte */ + if ((value_int = fgetc(file)) == EOF) + { + free(row_buffer); return FALSE; + } + value = (byte)value_int; } else @@ -186,6 +195,8 @@ static boolean PCX_ReadBitmap(FILE *file, struct PCX_Header *pcx, Image *image) bitmap_ptr += image->bytes_per_row; } + free(row_buffer); + return TRUE; }