[vlc-commits] hls: Removing calls to vlc_array_item_at_index

Hugo Beauzée-Luyssen git at videolan.org
Tue Jan 24 19:03:34 CET 2012


vlc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Tue Jan 24 18:09:36 2012 +0100| [d56ce5536ac6d4b583cf0d1ad462828cb745ca8d] | committer: Jean-Baptiste Kempf

hls: Removing calls to vlc_array_item_at_index

Using hls_Get and segment_GetSegment instead. Those check for out of
bound access.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

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

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 6cdebb3..1e63560 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -240,7 +240,7 @@ static void hls_Free(hls_stream_t *hls)
     {
         for (int n = 0; n < vlc_array_count(hls->segments); n++)
         {
-            segment_t *segment = (segment_t *)vlc_array_item_at_index(hls->segments, n);
+            segment_t *segment = segment_GetSegment(hls, n);
             if (segment) segment_Free(segment);
         }
         vlc_array_destroy(hls->segments);
@@ -310,7 +310,7 @@ static hls_stream_t *hls_Find(vlc_array_t *hls_stream, hls_stream_t *hls_new)
     int count = vlc_array_count(hls_stream);
     for (int n = 0; n < count; n++)
     {
-        hls_stream_t *hls = vlc_array_item_at_index(hls_stream, n);
+        hls_stream_t *hls = hls_Get(hls_stream, n);
         if (hls)
         {
             /* compare */
@@ -401,7 +401,7 @@ static segment_t *segment_Find(hls_stream_t *hls, const int sequence)
     if (count <= 0) return NULL;
     for (int n = 0; n < count; n++)
     {
-        segment_t *segment = vlc_array_item_at_index(hls->segments, n);
+        segment_t *segment = segment_GetSegment(hls, n);
         if (segment == NULL) break;
         if (segment->sequence == sequence)
             return segment;
@@ -1319,7 +1319,7 @@ static int get_HTTPLiveMetaPlaylist(stream_t *s, vlc_array_t **streams)
     for (int i = 0; i < vlc_array_count(p_sys->hls_stream); i++)
     {
         hls_stream_t *src, *dst;
-        src = (hls_stream_t *)vlc_array_item_at_index(p_sys->hls_stream, i);
+        src = hls_Get(p_sys->hls_stream, i);
         if (src == NULL)
             return VLC_EGENERIC;
 
@@ -1449,7 +1449,7 @@ static int hls_ReloadPlaylist(stream_t *s)
         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);
+            hls = hls_Get(hls_streams, i);
             if (hls) hls_Free(hls);
         }
         vlc_array_destroy(hls_streams);
@@ -2049,8 +2049,7 @@ fail:
     /* Free hls streams */
     for (int i = 0; i < vlc_array_count(p_sys->hls_stream); i++)
     {
-        hls_stream_t *hls;
-        hls = (hls_stream_t *)vlc_array_item_at_index(p_sys->hls_stream, i);
+        hls_stream_t *hls = hls_Get(p_sys->hls_stream, i);
         if (hls) hls_Free(hls);
     }
     vlc_array_destroy(p_sys->hls_stream);
@@ -2086,8 +2085,7 @@ static void Close(vlc_object_t *p_this)
     /* Free hls streams */
     for (int i = 0; i < vlc_array_count(p_sys->hls_stream); i++)
     {
-        hls_stream_t *hls;
-        hls = (hls_stream_t *)vlc_array_item_at_index(p_sys->hls_stream, i);
+        hls_stream_t *hls = hls_Get(p_sys->hls_stream, i);
         if (hls) hls_Free(hls);
     }
     vlc_array_destroy(p_sys->hls_stream);
@@ -2450,7 +2448,7 @@ static int segment_Seek(stream_t *s, const uint64_t pos)
 
     for (int n = 0; n < count; n++)
     {
-        segment_t *segment = vlc_array_item_at_index(hls->segments, n);
+        segment_t *segment = segment_GetSegment(hls, n);
         if (segment == NULL)
         {
             vlc_mutex_unlock(&hls->lock);



More information about the vlc-commits mailing list