stefan pushed a commit to branch master.

commit 9c1ed31c7675fa8bfd27f366b93b430287ffe552
Author: Stefan Schmidt <[email protected]>
Date:   Tue Jun 25 15:18:33 2013 +0100

    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.
---
 src/lib/eina/eina_list.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/lib/eina/eina_list.c b/src/lib/eina/eina_list.c
index 5c8b1f8..b4707c7 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)
    n = accounting->count;
    shuffled_list = shuffled_last = NULL;
 
+   if (n == 0)
+     return NULL;
+
    if (n == 1)
      return list;
 

-- 

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

Reply via email to