[vlc-commits] stream_filter/httplive.c: cleanup on failing to reload HLS Live playlist.

Jean-Paul Saman git at videolan.org
Wed Mar 2 23:51:12 CET 2011


vlc | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Fri Feb 25 16:47:27 2011 +0100| [738a285d5140d4fe6f3d0519125601725ddc2a62] | committer: Jean-Paul Saman

stream_filter/httplive.c: cleanup on failing to reload HLS Live playlist.

When reloading the HLS Playlist failes do not leak already allocated
hls_stream_t and segment_t structures. Instead cleanup.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=738a285d5140d4fe6f3d0519125601725ddc2a62
---

 modules/stream_filter/httplive.c |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 4a93891..5da0bf6 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -992,16 +992,29 @@ static int hls_ReloadPlaylist(stream_t *s)
         return VLC_ENOMEM;
 
     msg_Info(s, "Reloading HLS live meta playlist");
+
     if (get_HTTPLiveMetaPlaylist(s, &hls_streams) != VLC_SUCCESS)
-        goto fail;
+    {
+        /* Free hls streams */
+        for (int i = 0; i < vlc_array_count(hls_streams); i++)
+        {
+            hls_stream_t *hls;
+            hls = (hls_stream_t *)vlc_array_item_at_index(hls_streams, i);
+            if (hls) hls_Free(hls);
+        }
+        vlc_array_destroy(hls_streams);
 
-    int count = vlc_array_count(hls_streams);
+        msg_Err(s, "reloading playlist failed");
+        return VLC_EGENERIC;
+    }
 
     /* merge playlists */
+    int count = vlc_array_count(hls_streams);
     for (int n = 0; n < count; n++)
     {
         hls_stream_t *hls_new = hls_Get(hls_streams, n);
-        if (hls_new == NULL) goto fail;
+        if (hls_new == NULL)
+            continue;
 
         hls_stream_t *hls_old = hls_Find(p_sys->hls_stream, hls_new);
         if (hls_old == NULL)
@@ -1011,16 +1024,12 @@ static int hls_ReloadPlaylist(stream_t *s)
                      hls_new->id, hls_new->bandwidth);
         }
         else if (hls_UpdatePlaylist(s, hls_new, &hls_old) != VLC_SUCCESS)
-            goto fail;
+            msg_Info(s, "failed updating HLS stream (id=%d, bandwidth=%"PRIu64")",
+                     hls_new->id, hls_new->bandwidth);
     }
 
     vlc_array_destroy(hls_streams);
     return VLC_SUCCESS;
-
-fail:
-    msg_Err(s, "reloading playlist failed");
-    vlc_array_destroy(hls_streams);
-    return VLC_EGENERIC;
 }
 
 /****************************************************************************



More information about the vlc-commits mailing list