Browse code

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

(cherry picked from commit df2a45541c5e37907374c5e7595de1f30ea84f98)
(cherry picked from commit da06d9a4912f71b3e9f7af3d29a1543a4884efa9)

Daniel-Constantin Mierla authored on 29/01/2015 09:45:52
Showing 1 changed files
... ...
@@ -208,6 +208,7 @@ sca_set_config( sca_mod *scam )
208 208
 	LM_ERR( "Failed to shm_malloc module configuration" );
209 209
 	return( -1 );
210 210
     }
211
+    memset(scam->cfg, 0, sizeof( sca_config ));
211 212
 
212 213
     if ( outbound_proxy.s ) {
213 214
 	outbound_proxy.len = strlen( outbound_proxy.s );
... ...
@@ -295,23 +296,23 @@ sca_mod_init( void )
295 296
 
296 297
     if ( rpc_register_array( sca_rpc ) != 0 ) {
297 298
 	LM_ERR( "Failed to register RPC commands" );
298
-	return( -1 );
299
+	goto error;
299 300
     }
300 301
 
301 302
     if ( sca_bind_srdb1( sca, &dbf ) != 0 ) {
302 303
 	LM_ERR( "Failed to initialize required DB API" );
303
-	return( -1 );
304
+	goto error;
304 305
     }
305 306
 
306 307
     if ( load_tm_api( &tmb ) != 0 ) {
307 308
 	LM_ERR( "Failed to initialize required tm API" );
308
-	return( -1 );
309
+	goto error;
309 310
     }
310 311
     sca->tm_api = &tmb;
311 312
 
312 313
     if ( sca_bind_sl( sca, &slb ) != 0 ) {
313 314
 	LM_ERR( "Failed to initialize required sl API" );
314
-	return( -1 );
315
+	goto error;
315 316
     }
316 317
     
317 318
     if ( sca_hash_table_create( &sca->subscriptions,