[sr-dev] git:master:df2a4554: sca: more error handling during initialization of the module

Daniel-Constantin Mierla miconda at gmail.com
Thu Jan 29 10:48:46 CET 2015


Module: kamailio
Branch: master
Commit: df2a45541c5e37907374c5e7595de1f30ea84f98
URL: https://github.com/kamailio/kamailio/commit/df2a45541c5e37907374c5e7595de1f30ea84f98

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-01-29T10:45:52+01:00

sca: more error handling during initialization of the module

- fix crash when the module doesn't initialize and calls destroy
  function during shutdonw at startup
- reported by Olle E. Johansson, GH#57

---

Modified: modules/sca/sca.c

---

Diff:  https://github.com/kamailio/kamailio/commit/df2a45541c5e37907374c5e7595de1f30ea84f98.diff
Patch: https://github.com/kamailio/kamailio/commit/df2a45541c5e37907374c5e7595de1f30ea84f98.patch

---

diff --git a/modules/sca/sca.c b/modules/sca/sca.c
index e739e18..920024b 100644
--- a/modules/sca/sca.c
+++ b/modules/sca/sca.c
@@ -210,6 +210,7 @@ sca_set_config( sca_mod *scam )
 	LM_ERR( "Failed to shm_malloc module configuration" );
 	return( -1 );
     }
+    memset(scam->cfg, 0, sizeof( sca_config ));
 
     if ( outbound_proxy.s ) {
 	scam->cfg->outbound_proxy = &outbound_proxy;
@@ -293,23 +294,23 @@ sca_mod_init( void )
 
     if ( rpc_register_array( sca_rpc ) != 0 ) {
 	LM_ERR( "Failed to register RPC commands" );
-	return( -1 );
+	goto error;
     }
 
     if ( sca_bind_srdb1( sca, &dbf ) != 0 ) {
 	LM_ERR( "Failed to initialize required DB API" );
-	return( -1 );
+	goto error;
     }
 
     if ( load_tm_api( &tmb ) != 0 ) {
 	LM_ERR( "Failed to initialize required tm API" );
-	return( -1 );
+	goto error;
     }
     sca->tm_api = &tmb;
 
     if ( sca_bind_sl( sca, &slb ) != 0 ) {
 	LM_ERR( "Failed to initialize required sl API" );
-	return( -1 );
+	goto error;
     }
     
     if ( sca_hash_table_create( &sca->subscriptions,




More information about the sr-dev mailing list