[SR-Dev] git:master: lcr: fix double free on error

Andrei Pelinescu-Onciul andrei at iptel.org
Wed May 13 19:23:39 CEST 2009


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

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Wed May 13 19:15:24 2009 +0200

lcr: fix double free on error

On mod_init() error the lcr module did attempt to free twice all
the shared memory allocated vars (free_shared_memory() is called
twice on error, once when mod_init() fails and once when the
module destroy function is called).

---

 modules/lcr/lcr_mod.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/modules/lcr/lcr_mod.c b/modules/lcr/lcr_mod.c
index 9fc5089..41a3c43 100644
--- a/modules/lcr/lcr_mod.c
+++ b/modules/lcr/lcr_mod.c
@@ -699,27 +699,34 @@ static void free_shared_memory(void)
 {
     if (gws_1) {
         shm_free(gws_1);
+		gws_1=0;
     }
     if (gws_2) {
         shm_free(gws_2);
+		gws_2=0;
     }
     if (gws) {
         shm_free(gws);
+		gws=0;
     }
     if (lcrs_1) {
         lcr_hash_table_contents_free(lcrs_1);
         shm_free(lcrs_1);
+		lcrs_1=0;
     }
     if (lcrs_2) {
         lcr_hash_table_contents_free(lcrs_2);
         shm_free(lcrs_2);
+		lcrs_2=0;
     }
     if (lcrs) {
         shm_free(lcrs);
+		lcrs=0;
     }
     if (reload_lock) {
 	lock_destroy(reload_lock);
 	lock_dealloc(reload_lock);
+	reload_lock=0;
     }
 }
    




More information about the sr-dev mailing list