summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2013-06-25 15:18:33 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2013-06-25 15:18:33 +0100
commit9c1ed31c7675fa8bfd27f366b93b430287ffe552 (patch)
tree74c200f4120a84408259c9748f1770df7b349922
parent8deb75463bdb7f8aaa45bebdd3d1570655b66043 (diff)
eina_list: Avoid NULL pointer deref in eina_list_shuffle.
If we have a valid but empty, n = 0, list we never enter the loop and shuffled_last might still be NULL. Avoid this case by checking explicitly for n = 0 before.
-rw-r--r--src/lib/eina/eina_list.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/lib/eina/eina_list.c b/src/lib/eina/eina_list.c
index 5c8b1f8c41..b4707c7b36 100644
--- a/src/lib/eina/eina_list.c
+++ b/src/lib/eina/eina_list.c
@@ -1111,6 +1111,9 @@ eina_list_shuffle(Eina_List *list, Eina_Random_Cb func)
1111 n = accounting->count; 1111 n = accounting->count;
1112 shuffled_list = shuffled_last = NULL; 1112 shuffled_list = shuffled_last = NULL;
1113 1113
1114 if (n == 0)
1115 return NULL;
1116
1114 if (n == 1) 1117 if (n == 1)
1115 return list; 1118 return list;
1116 1119