Fixes: Assertion failure (invalid stream index) Fixes: 25120/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6565251898933248
Unified · Split
| @@ -530,20 +530,17 @@ static int ea_read_header(AVFormatContext *s) · 529 unmodified lines | ||
| 530 | 530 | if (ea->num_channels <= 0 || ea->num_channels > 2) { |
| 531 | 531 | av_log(s, AV_LOG_WARNING, |
| 532 | 532 | "Unsupported number of channels: %d\n", ea->num_channels); |
| 533 | − ea->audio_codec = 0; | |
| 534 | − return 1; | |
| 533 | + goto no_audio; | |
| 535 | 534 | } |
| 536 | 535 | if (ea->sample_rate <= 0) { |
| 537 | 536 | av_log(s, AV_LOG_ERROR, |
| 538 | 537 | "Unsupported sample rate: %d\n", ea->sample_rate); |
| 539 | − ea->audio_codec = 0; | |
| 540 | − return 1; | |
| 538 | + goto no_audio; | |
| 541 | 539 | } |
| 542 | 540 | if (ea->bytes <= 0 || ea->bytes > 2) { |
| 543 | 541 | av_log(s, AV_LOG_ERROR, |
| 544 | 542 | "Invalid number of bytes per sample: %d\n", ea->bytes); |
| 545 | − ea->audio_codec = AV_CODEC_ID_NONE; | |
| 546 | − return 1; | |
| 543 | + goto no_audio; | |
| 547 | 544 | } |
| 548 | 545 | |
| 549 | 546 | /* initialize the audio decoder stream */ |
| @@ -564,8 +561,13 @@ static int ea_read_header(AVFormatContext *s) · 14 unmodified lines | ||
| 564 | 561 | st->codecpar->bits_per_coded_sample; |
| 565 | 562 | ea->audio_stream_index = st->index; |
| 566 | 563 | st->start_time = 0; |
| 564 | + return 1; | |
| 567 | 565 | } |
| 566 | +no_audio: | |
| 567 | + ea->audio_codec = AV_CODEC_ID_NONE; | |
| 568 | 568 | |
| 569 | + if (!ea->video.codec) | |
| 570 | + return AVERROR_INVALIDDATA; | |
| 569 | 571 | return 1; |
| 570 | 572 | } |
| 571 | 573 | |