BAD tilman! what if the list is NULL! :)

SVN revision: 13163
This commit is contained in:
Carsten Haitzler 2005-02-01 03:04:26 +00:00
parent 158467be52
commit 506138f572
1 changed files with 2 additions and 5 deletions

View File

@ -703,16 +703,14 @@ evas_list_nth_list(Evas_List *list, int n)
Evas_List *l;
/* check for non-existing nodes */
if (n < 0 || n > list->count - 1) return NULL;
if ((n < 0) || (n > list->count - 1) || (!list)) return NULL;
/* if the node is in the 2nd half of the list, search from the end
* else, search from the beginning.
*/
if (n > list->count / 2)
{
n = list->count - n - 1;
for (i = 0, l = list->last; l; l = l->prev, i++)
for (i = list->count - 1, l = list->last; l; l = l->prev, i--)
{
if (i == n) return l;
}
@ -724,7 +722,6 @@ evas_list_nth_list(Evas_List *list, int n)
if (i == n) return l;
}
}
return NULL;
}