Simplify `p->buf > p->buf + p->buf_size - 4' as `p->buf_size < 4'. Avoid a possible out-of-bounds pointer, which is undefined behavior in C. CC: libav-stable@libav.org
Unified · Split
| @@ -279,11 +279,9 @@ static int flac_read_header(AVFormatContext *s) · 278 unmodified lines | |||
| 279 | 279 | ||
| 280 | static int flac_probe(AVProbeData *p) | 280 | static int flac_probe(AVProbeData *p) |
| 281 | { | 281 | { |
| 282 | uint8_t *bufptr = p->buf; | 282 | if (p->buf_size < 4 || memcmp(p->buf, "fLaC", 4)) |
| 283 | uint8_t *end = p->buf + p->buf_size; | 283 | return 0; |
| 284 | 284 | return AVPROBE_SCORE_MAX/2; | |
| 285 | if(bufptr > end-4 || memcmp(bufptr, "fLaC", 4)) return 0; | ||
| 286 | else return AVPROBE_SCORE_MAX/2; | ||
| 287 | } | 285 | } |
| 288 | 286 | ||
| 289 | AVInputFormat ff_flac_demuxer = { | 287 | AVInputFormat ff_flac_demuxer = { |