From 856c58aa9c47da9a1c42385d2923ebe4735e3a90 Mon Sep 17 00:00:00 2001
From: Gabriel Peixoto <gabrielrcp@gmail.com>
Date: Sun, 8 Sep 2013 02:24:30 -0300
Subject: [PATCH] find_subfiles: fix off-by-1 error

This could lead to a segfault, fixes #219

Signed-off-by: Gabriel Peixoto <gabrielrcp@gmail.com>
Signed-off-by: wm4 <wm4@nowhere>
---
 sub/find_subfiles.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sub/find_subfiles.c b/sub/find_subfiles.c
index f272e84e73..691c0148d3 100644
--- a/sub/find_subfiles.c
+++ b/sub/find_subfiles.c
@@ -212,7 +212,7 @@ static void filter_subidx(struct subfn **slist, int *nsub)
                 (*slist)[n].priority = -1;
         }
     }
-    for (int n = *nsub; n >= 0; n--) {
+    for (int n = *nsub - 1; n >= 0; n--) {
         if ((*slist)[n].priority < 0)
             MP_TARRAY_REMOVE_AT(*slist, *nsub, n);
     }