avformat: Add max_streams option

This allows user apps to stop OOM due to excessive number of streams

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer
2016-11-18 17:00:30 +01:00
parent da5c8284c0
commit 1296f84495
5 changed files with 15 additions and 3 deletions

View File

@@ -4217,7 +4217,7 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
int i;
AVStream **streams;
if (s->nb_streams >= INT_MAX/sizeof(*streams))
if (s->nb_streams >= FFMIN(s->max_streams, INT_MAX/sizeof(*streams)))
return NULL;
streams = av_realloc_array(s->streams, s->nb_streams + 1, sizeof(*streams));
if (!streams)