You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avformat/utils: Use av_realloc_array for reallocating array
Also improve the size check a bit; given that av_realloc_array() checks for overflow itself, we only have to check for nb_side_data + 1 still being representable in an int. But given that we can check for representability in size_t at no additional cost we do so as it leads to a nicer error code. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -1739,10 +1739,10 @@ int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((unsigned)st->nb_side_data + 1 >= INT_MAX / sizeof(*st->side_data))
|
if (st->nb_side_data + 1U > FFMIN(INT_MAX, SIZE_MAX / sizeof(*tmp)))
|
||||||
return AVERROR(ERANGE);
|
return AVERROR(ERANGE);
|
||||||
|
|
||||||
tmp = av_realloc(st->side_data, (st->nb_side_data + 1) * sizeof(*tmp));
|
tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));
|
||||||
if (!tmp) {
|
if (!tmp) {
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user