summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/flacdec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index f6d0abe544..3eb117acf6 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -226,9 +226,11 @@ static int get_metadata_size(const uint8_t *buf, int buf_size)
buf += 4;
do {
+ if (buf_end - buf < 4)
+ return 0;
ff_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size);
buf += 4;
- if (buf + metadata_size > buf_end) {
+ if (buf_end - buf < metadata_size) {
/* need more data in order to read the complete header */
return 0;
}