[vlc-commits] hls: Removing calls to vlc_array_item_at_index
Hugo Beauzée-Luyssen
git at videolan.org
Tue Jan 24 19:32:00 CET 2012
vlc/vlc-1.2 | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Tue Jan 24 18:09:36 2012 +0100| [7dcae00f4d1b4ffa77f63891f0f824be17f76609] | 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>
(cherry picked from commit d56ce5536ac6d4b583cf0d1ad462828cb745ca8d)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.2.git/?a=commit;h=7dcae00f4d1b4ffa77f63891f0f824be17f76609
---
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