# HG changeset patch # User kostya # Date 1266842112 0 # Node ID 1e9ff636c3db1aafbe76bc77ba5304fc6d2d70d4 # Parent eb773ca000d948bd21831cb1e8d430ca76fb9fb8 Make Bink decoder to stop decoding planes after all bits are used. This prevents crashes during decoding grayscale Bink files like samples from Impossible Creatures game demo. diff -r eb773ca000d9 -r 1e9ff636c3db bink.c --- a/bink.c Mon Feb 22 12:20:49 2010 +0000 +++ b/bink.c Mon Feb 22 12:35:12 2010 +0000 @@ -681,6 +681,7 @@ DECLARE_ALIGNED_16(DCTELEM, block[64]); DECLARE_ALIGNED_16(uint8_t, ublock[64]); int coordmap[64]; + int bits_count = pkt->size << 3; if(c->pic.data[0]) avctx->release_buffer(avctx, &c->pic); @@ -690,7 +691,7 @@ return -1; } - init_get_bits(&gb, pkt->data, pkt->size*8); + init_get_bits(&gb, pkt->data, bits_count); if (c->version >= 'i') skip_bits_long(&gb, 32); @@ -901,6 +902,8 @@ } if (get_bits_count(&gb) & 0x1F) //next plane data starts at 32-bit boundary skip_bits_long(&gb, 32 - (get_bits_count(&gb) & 0x1F)); + if (get_bits_count(&gb) >= bits_count) + break; } emms_c();