Jelajahi Sumber

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
Daniel-Constantin Mierla 10 tahun lalu
induk
melakukan
df2a45541c
1 mengubah file dengan 5 tambahan dan 4 penghapusan
  1. 5 4
      modules/sca/sca.c

+ 5 - 4
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,