Fixes: timeout (slow -> 300ms) Fixes: 28876/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5664824587583488
Unified · Split
| @@ -142,6 +142,11 @@ struct AVFormatInternal { · 141 unmodified lines | |||
| 142 | * Prefer the codec framerate for avg_frame_rate computation. | 142 | * Prefer the codec framerate for avg_frame_rate computation. |
| 143 | */ | 143 | */ |
| 144 | int prefer_codec_framerate; | 144 | int prefer_codec_framerate; |
| 145 | |||
| 146 | /** | ||
| 147 | * Set if chapter ids are strictly monotonic. | ||
| 148 | */ | ||
| 149 | int chapter_ids_monotonic; | ||
| 145 | }; | 150 | }; |
| 146 | 151 | ||
| 147 | struct AVStreamInternal { | 152 | struct AVStreamInternal { |
| @@ -4614,9 +4614,14 @@ AVChapter *avpriv_new_chapter(AVFormatContext *s, int id, AVRational time_base, · 4613 unmodified lines | |||
| 4614 | return NULL; | 4614 | return NULL; |
| 4615 | } | 4615 | } |
| 4616 | 4616 | ||
| 4617 | for (i = 0; i < s->nb_chapters; i++) | 4617 | if (!s->nb_chapters) { |
| 4618 | if (s->chapters[i]->id == id) | 4618 | s->internal->chapter_ids_monotonic = 1; |
| 4619 | chapter = s->chapters[i]; | 4619 | } else if (!s->internal->chapter_ids_monotonic || s->chapters[s->nb_chapters-1]->id >= id) { |
| 4620 | s->internal->chapter_ids_monotonic = 0; | ||
| 4621 | for (i = 0; i < s->nb_chapters; i++) | ||
| 4622 | if (s->chapters[i]->id == id) | ||
| 4623 | chapter = s->chapters[i]; | ||
| 4624 | } | ||
| 4620 | 4625 | ||
| 4621 | if (!chapter) { | 4626 | if (!chapter) { |
| 4622 | chapter = av_mallocz(sizeof(AVChapter)); | 4627 | chapter = av_mallocz(sizeof(AVChapter)); |