[FFmpeg-devel] lavf/dashdec: Fix memleak

Submitted by Steven Liu on Aug. 2, 2018, 2:03 a.m.

Details

Message ID 55C74722-66F1-47C7-BC27-842F3C9DE4FE@chinaffmpeg.org
State New
Headers show

Commit Message

Steven Liu Aug. 2, 2018, 2:03 a.m.
> 在 2018年8月1日,下午6:03,jacek jogo <overx300@gmail.com> 写道:
> 
> Hi.
> This fix memleak in dashdec.
> ==5033== HEAP SUMMARY:
> ==5033==     in use at exit: 86,144 bytes in 2,848 blocks
> ==5033==   total heap usage: 10,089 allocs, 7,241 frees, 38,902,613 bytes
> allocated
> ==5033==
> ==5033== Searching for pointers to 2,848 not-freed blocks
> ==5033== Checked 9,139,304 bytes
> ==5033==
> ==5033== 528 bytes in 8 blocks are definitely lost in loss record 187 of 222
> ==5033==    at 0x4C2CB5F: malloc (vg_replace_malloc.c:299)
> ==5033==    by 0x6868D38: xmlBufCreateSize (in /usr/lib64/libxml2.so.2.9.8)
> ==5033==    by 0x67F1029: xmlNodeGetContent (in /usr/lib64/libxml2.so.2.9.8)
> ==5033==    by 0x41EA43: resolve_content_path (dashdec.c:757)
> ==5033==    by 0x41EA43: parse_manifest_representation (dashdec.c:873)
> ==5033==    by 0x41EA43: parse_manifest_adaptationset (dashdec.c:1095)
> ==5033==    by 0x41EA43: parse_manifest (dashdec.c:1272)
> ==5033==    by 0x420E2A: dash_read_header (dashdec.c:1927)
> ==5033==    by 0x53CF77: avformat_open_input (utils.c:631)
> ==5033==    by 0x2647F4: open_input_file (ffmpeg_opt.c:1069)
> ==5033==    by 0x266121: open_files (ffmpeg_opt.c:3219)
> ==5033==    by 0x266121: ffmpeg_parse_options (ffmpeg_opt.c:3259)
> ==5033==    by 0x25E991: main (ffmpeg.c:4859)
> ==5033==
> ==5033== LEAK SUMMARY:
> ==5033==    definitely lost: 528 bytes in 8 blocks
> ==5033==    indirectly lost: 0 bytes in 0 blocks
> ==5033==      possibly lost: 0 bytes in 0 blocks
> ==5033==    still reachable: 85,616 bytes in 2,840 blocks
> ==5033==         suppressed: 0 bytes in 0 blocks
> ==5033== Reachable blocks (those to which a pointer was found) are not
> shown.
> ==5033== To see them, rerun with: --leak-check=full --show-leak-kinds=all
> ==5033==
> ==5033== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
> ==5033== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
> 
> Can be reproduced with:  valgrind  --leak-check=full  -v ffmpeg -i
> http://yt-dash-mse-test.commondatastorage.googleapis.com/media/motion-20120802-manifest.mpd
> <0001-lavf-dashdec-Fix-memleak.patch>_______________________________________________


what about 
modify 
---
libavformat/dashdec.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)





> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Patch hide | download patch | download mbox

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 89f3ac2759..010a2e8387 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -754,9 +754,12 @@  static int resolve_content_path(AVFormatContext *s, const char *url, int *max_ur
        if (!(node = baseurl_nodes[rootId])) {
            continue;
        }
-        if (ishttp(xmlNodeGetContent(node))) {
+        text = xmlNodeGetContent(node);
+        if (ishttp(text)) {
+            xmlFree(text);
            break;
        }
+        xmlFree(text);
    }

    node = baseurl_nodes[rootId];
-- 
2.18.0

to 


From 1fa3d049a17dd4d135bb79423e0551ee7ee7f25d Mon Sep 17 00:00:00 2001
From: Jacek Jendrzej <overx300@gmail.com>
Date: Wed, 1 Aug 2018 11:53:41 +0200
Subject: [PATCH] lavf/dashdec: Fix memleak

---
libavformat/dashdec.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 89f3ac2759..010a2e8387 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -754,9 +754,12 @@  static int resolve_content_path(AVFormatContext *s, const char *url, int *max_ur
        if (!(node = baseurl_nodes[rootId])) {
            continue;
        }
-        if (ishttp(xmlNodeGetContent(node))) {
+        text = xmlNodeGetContent(node);
+        xmlFree(text);
+        if (ishttp(text)) {
            break;
        }
    }

    node = baseurl_nodes[rootId];
-- 
2.18.0