diff mbox

[FFmpeg-devel] avformat/dashdec: fix pointer being freed was not allocated

Message ID 20190913163402.91777-1-hello.vectronic@gmail.com
State Superseded
Headers show

Commit Message

vectronic Sept. 13, 2019, 4:34 p.m. UTC
prevent attempt to call xmlFree if val was not allocated

fixes: 8135
Signed-off-by: vectronic <hello.vectronic@gmail.com>
---
 libavformat/dashdec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Carl Eugen Hoyos Sept. 13, 2019, 5:05 p.m. UTC | #1
Am Fr., 13. Sept. 2019 um 18:34 Uhr schrieb vectronic
<hello.vectronic@gmail.com>:
>
> prevent attempt to call xmlFree if val was not allocated
>
> fixes: 8135
> Signed-off-by: vectronic <hello.vectronic@gmail.com>
> ---
>  libavformat/dashdec.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 4f725ba09a..8022ba9afe 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -1185,6 +1185,7 @@ static int parse_programinformation(AVFormatContext *s, xmlNodePtr node)
>
>      node = xmlFirstElementChild(node);
>      while (node) {
> +        val = NULL;
>          if (!av_strcasecmp(node->name, "Title")) {
>              val = xmlNodeGetContent(node);
>              if (val) {

This part of the patch is sufficient afaict.

> @@ -1202,7 +1203,9 @@ static int parse_programinformation(AVFormatContext *s, xmlNodePtr node)
>              }
>          }
>          node = xmlNextElementSibling(node);
> -        xmlFree(val);
> +        if (val) {
> +            xmlFree(val);
> +        }

This - fortunately - seems unneeded.

Carl Eugen
diff mbox

Patch

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 4f725ba09a..8022ba9afe 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -1185,6 +1185,7 @@  static int parse_programinformation(AVFormatContext *s, xmlNodePtr node)
 
     node = xmlFirstElementChild(node);
     while (node) {
+        val = NULL;
         if (!av_strcasecmp(node->name, "Title")) {
             val = xmlNodeGetContent(node);
             if (val) {
@@ -1202,7 +1203,9 @@  static int parse_programinformation(AVFormatContext *s, xmlNodePtr node)
             }
         }
         node = xmlNextElementSibling(node);
-        xmlFree(val);
+        if (val) {
+            xmlFree(val);
+        }
     }
     return 0;
 }