[FFmpeg-devel] [PATCH 2/2] webmdashenc: Fix potential leak in realloc

Vignesh Venkatasubramanian vigneshv at google.com
Mon Apr 13 21:16:44 CEST 2015


Fix potential leak in av_realloc call where the output was being
overwritten by using a temporary variable.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv at google.com>
---
 libavformat/webmdashenc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index 80266f7..0f915fd 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -419,9 +419,10 @@ static int parse_adaptation_sets(AVFormatContext *s)
         if (*p == ' ')
             continue;
         else if (state == new_set && !strncmp(p, "id=", 3)) {
-            w->as = av_realloc(w->as, sizeof(*w->as) * ++w->nb_as);
-            if (w->as == NULL)
+            void *mem = av_realloc(w->as, sizeof(*w->as) * ++w->nb_as);
+            if (mem == NULL)
                 return AVERROR(ENOMEM);
+            w->as = mem;
             w->as[w->nb_as - 1].nb_streams = 0;
             w->as[w->nb_as - 1].streams = NULL;
             p += 3; // consume "id="
-- 
2.2.0.rc0.207.ga3a616c



More information about the ffmpeg-devel mailing list