Browse code

sca: initialize sca variable to catch destroy on shutdown at startup

- reported by GH#35

(cherry picked from commit 010977f5febcf923a31d545bd631fbee11dd426c)
(cherry picked from commit 0d47a5cfc723be2b8ef2baeb439d5df05b5c580c)

Daniel-Constantin Mierla authored on 28/01/2015 21:09:21
Showing 1 changed files
... ...
@@ -40,7 +40,7 @@
40 40
 MODULE_VERSION
41 41
 
42 42
 /* MODULE OBJECT */
43
-sca_mod			*sca;
43
+sca_mod			*sca = NULL;
44 44
 
45 45
 
46 46
 /* EXTERNAL API */
... ...
@@ -365,10 +365,15 @@ error:
365 365
     void
366 366
 sca_mod_destroy( void )
367 367
 {
368
+	if(sca==0)
369
+		return;
370
+
368 371
     /* write back to the DB to retain most current subscription info */
369 372
     if ( sca_subscription_db_update() != 0 ) {
370
-	LM_ERR( "sca_mod_destroy: failed to save current subscriptions "
371
-		"in DB %.*s", STR_FMT( sca->cfg->db_url ));
373
+		if(sca && sca->cfg && sca->cfg->db_url) {
374
+			LM_ERR( "sca_mod_destroy: failed to save current subscriptions "
375
+				"in DB %.*s", STR_FMT( sca->cfg->db_url ));
376
+		}
372 377
     }
373 378
 
374 379
     sca_db_disconnect();