[vlc-commits] player: move track limit check

Thomas Guillem git at videolan.org
Wed Feb 26 13:12:33 CET 2020


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Feb 19 13:51:21 2020 +0100| [5a09921f88c0b9d23cfca162a5fe062b47142ab3] | committer: Thomas Guillem

player: move track limit check

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

 src/player/player.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/player/player.c b/src/player/player.c
index 97a1bc857d..73c8c87f89 100644
--- a/src/player/player.c
+++ b/src/player/player.c
@@ -461,8 +461,8 @@ vlc_player_SelectEsIdList(vlc_player_t *player,
     /* First, count and hold all the ES Ids.
        Ids will be released in input.c:ControlRelease */
     size_t track_count = 0;
-    for (size_t i = 0; es_id_list[i] != NULL; i++)
-        if (track_count < max_tracks && vlc_es_id_GetCat(es_id_list[i]) == cat)
+    for (size_t i = 0; es_id_list[i] != NULL && track_count < max_tracks; i++)
+        if (vlc_es_id_GetCat(es_id_list[i]) == cat)
             track_count++;
 
     /* Copy es_id_list into an allocated list so that it remains in memory until
@@ -474,10 +474,10 @@ vlc_player_SelectEsIdList(vlc_player_t *player,
         return 0;
 
     track_count = 0;
-    for (size_t i = 0; es_id_list[i] != NULL; i++)
+    for (size_t i = 0; es_id_list[i] != NULL && track_count < max_tracks; i++)
     {
         vlc_es_id_t *es_id = es_id_list[i];
-        if (track_count < max_tracks && vlc_es_id_GetCat(es_id_list[i]) == cat)
+        if (vlc_es_id_GetCat(es_id_list[i]) == cat)
         {
             vlc_es_id_Hold(es_id);
             allocated_ids[track_count++] = es_id;



More information about the vlc-commits mailing list