Prechádzať zdrojové kódy

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).
Andrei Pelinescu-Onciul 16 rokov pred
rodič
commit
b974149715
1 zmenil súbory, kde vykonal 7 pridanie a 0 odobranie
  1. 7 0
      modules/lcr/lcr_mod.c

+ 7 - 0
modules/lcr/lcr_mod.c

@@ -699,27 +699,34 @@ static void free_shared_memory(void)
 {
 {
     if (gws_1) {
     if (gws_1) {
         shm_free(gws_1);
         shm_free(gws_1);
+		gws_1=0;
     }
     }
     if (gws_2) {
     if (gws_2) {
         shm_free(gws_2);
         shm_free(gws_2);
+		gws_2=0;
     }
     }
     if (gws) {
     if (gws) {
         shm_free(gws);
         shm_free(gws);
+		gws=0;
     }
     }
     if (lcrs_1) {
     if (lcrs_1) {
         lcr_hash_table_contents_free(lcrs_1);
         lcr_hash_table_contents_free(lcrs_1);
         shm_free(lcrs_1);
         shm_free(lcrs_1);
+		lcrs_1=0;
     }
     }
     if (lcrs_2) {
     if (lcrs_2) {
         lcr_hash_table_contents_free(lcrs_2);
         lcr_hash_table_contents_free(lcrs_2);
         shm_free(lcrs_2);
         shm_free(lcrs_2);
+		lcrs_2=0;
     }
     }
     if (lcrs) {
     if (lcrs) {
         shm_free(lcrs);
         shm_free(lcrs);
+		lcrs=0;
     }
     }
     if (reload_lock) {
     if (reload_lock) {
 	lock_destroy(reload_lock);
 	lock_destroy(reload_lock);
 	lock_dealloc(reload_lock);
 	lock_dealloc(reload_lock);
+	reload_lock=0;
     }
     }
 }
 }