Revision
15076
Author
mrene
Date
2009-10-04 02:40:12 -0500 (Sun, 04 Oct 2009)

Log Message

mod_directory: fix segfault on failure

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/applications/mod_directory/mod_directory.c (15075 => 15076)


--- freeswitch/trunk/src/mod/applications/mod_directory/mod_directory.c	2009-10-04 06:08:25 UTC (rev 15075)
+++ freeswitch/trunk/src/mod/applications/mod_directory/mod_directory.c	2009-10-04 07:40:12 UTC (rev 15076)
@@ -833,10 +833,14 @@
 	int attempts = 3;
 	char macro[255];
 
-	if (!switch_strlen_zero(data)) {
-		mydata = switch_core_session_strdup(session, data);
-		argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+	if (switch_strlen_zero(data)) {
+		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missing profile name\n");
+		return;
 	}
+
+	mydata = switch_core_session_strdup(session, data);
+	argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
 	if (argv[x]) {
 		profile_name = argv[x++];
 	}
@@ -845,10 +849,9 @@
 		domain_name = argv[x++];
 	}
 
-
 	if (!(profile = get_profile(profile_name))) {
 		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name);
-		goto end;
+		return;
 	}
 
 	populate_database(session, profile, domain_name);
@@ -888,15 +891,11 @@
 		switch_ivr_session_transfer(session, s_param.transfer_to, "XML", domain_name);
 	}
 
-end:
 	/* Delete all sql entry for this call */
 	sql = switch_mprintf("delete from directory_search where hostname = '%q' and uuid = '%q'", globals.hostname, switch_core_session_get_uuid(session));
 	directory_execute_sql(sql, profile->mutex);
 	switch_safe_free(sql);
-
-
-	profile_rwunlock(profile);
-
+	profile_rwunlock(profile);	
 }
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_directory_load)
@@ -929,7 +928,6 @@
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open db name : %s\n", globals.dbname);
 		return SWITCH_STATUS_FALSE;
-
 	}
 
 	sql = switch_mprintf("delete from directory_search where hostname = '%q'", globals.hostname);