diff mbox

[FFmpeg-devel,2/2] avformat/utils: Print verbose error message if stream count exceeds max_streams

Message ID 20161210191513.29783-2-michael@niedermayer.cc
State Accepted
Commit f0bdd538712d8ed34120ab2b7bd1409fcc99fb45
Headers show

Commit Message

Michael Niedermayer Dec. 10, 2016, 7:15 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/utils.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Andreas Cadhalpun Dec. 12, 2016, 11:33 p.m. UTC | #1
On 10.12.2016 20:15, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/utils.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 9e979a7c79..897352924d 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -4217,8 +4217,11 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
>      int i;
>      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;
> +    }
>      streams = av_realloc_array(s->streams, s->nb_streams + 1, sizeof(*streams));
>      if (!streams)
>          return NULL;
> 

This is probably OK.

Best regards,
Andreas
diff mbox

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 9e979a7c79..897352924d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4217,8 +4217,11 @@  AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
     int i;
     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;
+    }
     streams = av_realloc_array(s->streams, s->nb_streams + 1, sizeof(*streams));
     if (!streams)
         return NULL;