avformat/utils: Print verbose error message if stream count exceeds max_streams

Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f0bdd53871)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2016-12-10 20:15:13 +01:00
parent 3e3e095fc9
commit 9519b2560e

View File

@ -4213,8 +4213,11 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
int i; int i;
AVStream **streams; AVStream **streams;
if (s->nb_streams >= FFMIN(s->max_streams, INT_MAX/sizeof(*streams))) if (s->nb_streams >= FFMIN(s->max_streams, INT_MAX/sizeof(*streams))) {
if (s->max_streams < INT_MAX/sizeof(*streams))
av_log(s, AV_LOG_ERROR, "Number of streams exceeds max_streams parameter (%d), see the documentation if you wish to increase it\n", s->max_streams);
return NULL; return NULL;
}
streams = av_realloc_array(s->streams, s->nb_streams + 1, sizeof(*streams)); streams = av_realloc_array(s->streams, s->nb_streams + 1, sizeof(*streams));
if (!streams) if (!streams)
return NULL; return NULL;