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.rheinha...@outlook.com> --- libavformat/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 19f5ae720c..a905838468 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -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); - 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) { return AVERROR(ENOMEM); } -- 2.32.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".