Eina_List: Avoid Segfault
authoretrunko <etrunko@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 14 Sep 2010 18:29:30 +0000 (18:29 +0000)
committeretrunko <etrunko@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 14 Sep 2010 18:29:30 +0000 (18:29 +0000)
Some inputs in which tmp - cur is greater than the number of previous nodes
in list, were causing ct to be null at end of loop.

Patch by Jonas M. Gastal <jgastal@profusion.mobi>

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@52253 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/eina_list.c

index 68f5b3e..3ce6131 100644 (file)
@@ -1859,6 +1859,9 @@ eina_list_search_sorted_near_list(const Eina_List *list,
         else if (tmp > cur)
            for (; tmp != cur; tmp--, ct = ct->prev) ;
 
+        if (!ct)
+           goto end;
+
         cmp = func(ct->data, data);
         if (cmp == 0)
            break;