Fixes out of array accesses
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -289,7 +289,9 @@ static int cdg_decode_frame(AVCodecContext *avctx, |
289 | 289 |
inst = bytestream_get_byte(&buf); |
290 | 290 |
inst &= CDG_MASK; |
291 | 291 |
buf += 2; /// skipping 2 unneeded bytes |
292 |
- bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE); |
|
292 |
+ |
|
293 |
+ if (buf_size > CDG_HEADER_SIZE) |
|
294 |
+ bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE); |
|
293 | 295 |
|
294 | 296 |
if ((command & CDG_MASK) == CDG_COMMAND) { |
295 | 297 |
switch (inst) { |