Permalink
Browse files

Null deref if you read off the end of a list. Thank you xulfur for fi…

…nding that
  • Loading branch information...
1 parent 310f6cb commit 9d01850914bc12b6400f6a92298e7fa5367f17bf Caleb James DeLisle committed with Ralith Mar 1, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 benc/List.c
View
@@ -87,10 +87,12 @@ static Object* getObject(const List* list, uint32_t index)
if (list != NULL && *list != NULL) {
struct List_Item* entry = *list;
uint32_t i;
- for (i = 0; i < index && entry != NULL; i++) {
+ for (i = 0; entry != NULL; i++) {
+ if (i == index) {
+ return entry->elem;
+ }
entry = entry->next;
}
- return entry->elem;
}
return NULL;
}

0 comments on commit 9d01850

Please sign in to comment.