Module: sip-router
Branch: master
Commit: 72938bf706a75ecd4edf63dcfa2551b9ce40976b
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=72938bf706a75ecd4edf63dcfa2551b9ce40976b

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date:   Sun May 22 17:21:54 2011 +0200

htable: check if hash table entries are initialized in detroy function

- one of last updates to htable changed initialization to be directly in
  shared memory, while hash table slots are initialied in mod init
  funtion, causing crash of the module if config file has errors and
  proper starting does not happen
- reported by Juha Heinanen

---

 modules_k/htable/ht_api.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/modules_k/htable/ht_api.c b/modules_k/htable/ht_api.c
index da473e6..5c5298b 100644
--- a/modules_k/htable/ht_api.c
+++ b/modules_k/htable/ht_api.c
@@ -320,20 +320,23 @@ int ht_destroy(void)
        while(ht)
        {
                ht0 = ht->next;
-               for(i=0; i<ht->htsize; i++)
+               if(ht->entries!=NULL)
                {
-                       /* free entries */
-                       it = ht->entries[i].first;
-                       while(it)
+                       for(i=0; i<ht->htsize; i++)
                        {
-                               it0 = it;
-                               it = it->next;
-                               ht_cell_free(it0);
+                               /* free entries */
+                               it = ht->entries[i].first;
+                               while(it)
+                               {
+                                       it0 = it;
+                                       it = it->next;
+                                       ht_cell_free(it0);
+                               }
+                               /* free locks */
+                               lock_destroy(&ht->entries[i].lock);
                        }
-                       /* free locks */
-                       lock_destroy(&ht->entries[i].lock);
+                       shm_free(ht->entries);
                }
-               shm_free(ht->entries);
                shm_free(ht);
                ht = ht0;
        }


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to