summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8beeb6e)
raw | patch | inline | side by side (parent: 8beeb6e)
author | Max Kellermann <max@duempel.org> | |
Sun, 21 Sep 2008 20:45:04 +0000 (22:45 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sun, 21 Sep 2008 20:45:04 +0000 (22:45 +0200) |
Don't call filelist_get() with an invalid index.
src/screen_browser.c | patch | blob | history | |
src/screen_file.c | patch | blob | history |
diff --git a/src/screen_browser.c b/src/screen_browser.c
index d2c8aa08ef799d7aec00cc0c1670a4769e9d842b..4c8bc2ed6cccfd5421a36d51af7aff9be09bdc45 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
static struct filelist_entry *
browser_get_selected(const struct screen_browser *browser)
{
- if (browser->filelist == NULL)
+ if (browser->filelist == NULL ||
+ browser->lw->selected >= filelist_length(browser->filelist))
return NULL;
return filelist_get(browser->filelist, browser->lw->selected);
diff --git a/src/screen_file.c b/src/screen_file.c
index 9dd59001cc84ec3ad0bf348fa1e092527397cae6..26b2739720703668506e68491f31307a5bcbe50d 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.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;
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;