mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-10-06 09:22:36 +08:00
avformat/utils: Don't allocate zero-sized array
It is unnecessary and also ill-defined: av_malloc() returns a 1-byte block of memory in this case, but this is not documented. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -3167,15 +3167,19 @@ static int compute_chapters_end(AVFormatContext *s)
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int64_t max_time = 0;
|
int64_t max_time = 0;
|
||||||
AVChapter **timetable = av_malloc(s->nb_chapters * sizeof(*timetable));
|
AVChapter **timetable;
|
||||||
|
|
||||||
if (!timetable)
|
if (!s->nb_chapters)
|
||||||
return AVERROR(ENOMEM);
|
return 0;
|
||||||
|
|
||||||
if (s->duration > 0 && s->start_time < INT64_MAX - s->duration)
|
if (s->duration > 0 && s->start_time < INT64_MAX - s->duration)
|
||||||
max_time = s->duration +
|
max_time = s->duration +
|
||||||
((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time);
|
((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time);
|
||||||
|
|
||||||
|
timetable = av_malloc(s->nb_chapters * sizeof(*timetable));
|
||||||
|
if (!timetable)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
for (i = 0; i < s->nb_chapters; i++)
|
for (i = 0; i < s->nb_chapters; i++)
|
||||||
timetable[i] = s->chapters[i];
|
timetable[i] = s->chapters[i];
|
||||||
qsort(timetable, s->nb_chapters, sizeof(*timetable), chapter_start_cmp);
|
qsort(timetable, s->nb_chapters, sizeof(*timetable), chapter_start_cmp);
|
||||||
|
Reference in New Issue
Block a user