aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen_file.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-21 22:45:04 +0200
committerMax Kellermann <max@duempel.org>2008-09-21 22:45:04 +0200
commitba91edfee95a6198e2db9804fee9ddfeffa8a199 (patch)
treea6d7516ca294625630c99d88e3f8088539108be7 /src/screen_file.c
parent8beeb6e1d2311a3593a3df0273b778011068e81b (diff)
downloadmpd-ba91edfee95a6198e2db9804fee9ddfeffa8a199.tar.gz
mpd-ba91edfee95a6198e2db9804fee9ddfeffa8a199.tar.xz
mpd-ba91edfee95a6198e2db9804fee9ddfeffa8a199.zip
browser: check if the selection is valid
Don't call filelist_get() with an invalid index.
Diffstat (limited to 'src/screen_file.c')
-rw-r--r--src/screen_file.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/screen_file.c b/src/screen_file.c
index 9dd59001c..26b273972 100644
--- a/src/screen_file.c
+++ b/src/screen_file.c
@@ -62,6 +62,9 @@ handle_save(screen_t *screen, mpdclient_t *c)
filelist_entry_t *entry;
char *defaultname = NULL;
+ if (browser.lw->selected >= filelist_length(browser.filelist))
+ return -1;
+
entry = filelist_get(browser.filelist, browser.lw->selected);
if( entry && entry->entity ) {
mpd_InfoEntity *entity = entry->entity;
@@ -83,6 +86,9 @@ handle_delete(screen_t *screen, mpdclient_t *c)
char *str, *buf;
int key;
+ if (browser.lw->selected >= filelist_length(browser.filelist))
+ return -1;
+
entry = filelist_get(browser.filelist, browser.lw->selected);
if( entry==NULL || entry->entity==NULL )
return -1;