Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore


Modified Files:
        ecore_hash.c 


Log Message:
Catch a potential segfault if a hash is created and never used.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore/ecore_hash.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- ecore_hash.c        17 Nov 2005 15:15:37 -0000      1.21
+++ ecore_hash.c        2 Dec 2005 15:35:50 -0000       1.22
@@ -180,23 +180,26 @@
 
        ECORE_WRITE_LOCK(hash);
 
-       while (i < ecore_prime_table[hash->size]) {
-               if (hash->buckets[i]) {
-                       Ecore_Hash_Node *bucket;
-
-                       /*
-                        * Remove the bucket list to avoid possible recursion
-                        * on the free callbacks.
-                        */
-                       bucket = hash->buckets[i];
-                       hash->buckets[i] = NULL;
-                       _ecore_hash_bucket_destroy(bucket,
-                                       hash->free_key, hash->free_value);
+       if (hash->buckets) {
+               while (i < ecore_prime_table[hash->size]) {
+                       if (hash->buckets[i]) {
+                               Ecore_Hash_Node *bucket;
+
+                               /*
+                                * Remove the bucket list to avoid possible 
recursion
+                                * on the free callbacks.
+                                */
+                               bucket = hash->buckets[i];
+                               hash->buckets[i] = NULL;
+                               _ecore_hash_bucket_destroy(bucket,
+                                               hash->free_key,
+                                               hash->free_value);
+                       }
+                       i++;
                }
-               i++;
-       }
 
-       FREE(hash->buckets);
+               FREE(hash->buckets);
+       }
 
        ECORE_WRITE_UNLOCK(hash);
        ECORE_DESTROY_LOCKS(hash);




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to