[vlc-devel] [PATCH] relative_URI memory leak cleanup

Brian.Kurle at arrisi.com Brian.Kurle at arrisi.com
Thu Dec 2 00:04:11 CET 2010


From: Brian Kurle <Brian.Kurle at arrisi.com>

If the the link is relative, psz_uri is dynamically allocated a string of the
absolute URI (which is also returned by the function).   However, if it isn't,
NULL is returned and nothing is allocated.   segment_New performs a strdup, so
the pointer is not saved.   Thus, check if the allocation occurred and clean up
if needed.
---
 modules/stream_filter/httplive.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index d1d441a..71172be 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -378,6 +378,8 @@ static void parse_SegmentInformation(stream_t *s, hls_stream_t *hls, char *p_rea
 
     vlc_mutex_lock(&hls->lock);
     segment_t *segment = segment_New(hls, duration, psz_uri ? psz_uri : uri);
+    if( psz_uri != NULL )
+        free( psz_uri );
     if (segment)
         segment->sequence = hls->sequence + vlc_array_count(hls->segments);
     if (duration > hls->duration)
@@ -447,6 +449,8 @@ static void parse_StreamInformation(stream_t *s, char *p_read, char *uri)
     psz_uri = relative_URI(s, uri, psz_uri);
 
     hls_stream_t *hls = hls_New(p_sys->hls_stream, id, bw, psz_uri ? psz_uri : uri);
+    if( psz_uri != NULL )
+        free( psz_uri );
     if (hls == NULL)
         p_sys->b_error = true;
 }
-- 
1.7.1




More information about the vlc-devel mailing list