rtsp: Don't use av_malloc(0) if there are no streams
authorMartin Storsjö <martin@martin.st>
Fri, 6 Apr 2012 19:36:16 +0000 (22:36 +0300)
committerMartin Storsjö <martin@martin.st>
Sun, 8 Apr 2012 12:51:33 +0000 (15:51 +0300)
Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/rtspdec.c

index 9306384..063e825 100644 (file)
@@ -159,8 +159,9 @@ static int rtsp_read_header(AVFormatContext *s)
     if (ret)
         return ret;
 
-    rt->real_setup_cache = av_mallocz(2 * s->nb_streams * sizeof(*rt->real_setup_cache));
-    if (!rt->real_setup_cache)
+    rt->real_setup_cache = !s->nb_streams ? NULL :
+                           av_mallocz(2 * s->nb_streams * sizeof(*rt->real_setup_cache));
+    if (!rt->real_setup_cache && s->nb_streams)
         return AVERROR(ENOMEM);
     rt->real_setup = rt->real_setup_cache + s->nb_streams;