From 8570a2d719fa98fc221b81f6c0e66202fa07e741 Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthony.minessale@gmail.com>
Date: Fri, 10 Apr 2009 21:37:17 +0000
Subject: [PATCH] refactor

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12989 d0543943-73ff-0310-b7d9-9358b9ac24b2
---
 src/switch_core_memory.c  | 17 ++++++++++++++++-
 src/switch_core_session.c | 10 ++++------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/switch_core_memory.c b/src/switch_core_memory.c
index df53ee1261..28c87337c3 100644
--- a/src/switch_core_memory.c
+++ b/src/switch_core_memory.c
@@ -135,8 +135,13 @@ SWITCH_DECLARE(char *) switch_core_perform_permanent_strdup(const char *todup, c
 	switch_size_t len;
 	switch_assert(memory_manager.memory_pool != NULL);
 
-	if (!todup)
+	if (!todup) {
 		return NULL;
+	}
+
+	if (switch_strlen_zero(todup)) {
+		return SWITCH_BLANK_STRING;
+	}
 
 #ifdef LOCK_MORE
 #ifdef USE_MEM_LOCK
@@ -229,6 +234,11 @@ SWITCH_DECLARE(char *) switch_core_perform_session_strdup(switch_core_session_t
 	if (!todup) {
 		return NULL;
 	}
+
+	if (switch_strlen_zero(todup)) {
+		return SWITCH_BLANK_STRING;
+	}
+
 #ifdef LOCK_MORE
 #ifdef USE_MEM_LOCK
 	switch_mutex_lock(memory_manager.mem_lock);
@@ -264,6 +274,11 @@ SWITCH_DECLARE(char *) switch_core_perform_strdup(switch_memory_pool_t *pool, co
 	if (!todup) {
 		return NULL;
 	}
+
+	if (switch_strlen_zero(todup)) {
+		return SWITCH_BLANK_STRING;
+	}
+
 #ifdef LOCK_MORE
 #ifdef USE_MEM_LOCK
 	switch_mutex_lock(memory_manager.mem_lock);
diff --git a/src/switch_core_session.c b/src/switch_core_session.c
index aeaa099fda..ed81ba2ed6 100644
--- a/src/switch_core_session.c
+++ b/src/switch_core_session.c
@@ -1447,19 +1447,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(switch_core_se
 	session->stack_count++;
 
 	new_profile = switch_caller_profile_clone(session, profile);
-	new_profile->destination_number = switch_core_session_strdup(session, exten);
+	new_profile->destination_number = switch_core_strdup(new_profile->pool, exten);
 
 	if (!switch_strlen_zero(dialplan)) {
-		new_profile->dialplan = switch_core_session_strdup(session, dialplan);
+		new_profile->dialplan = switch_core_strdup(new_profile->pool, dialplan);
 	}
 
 	if (!switch_strlen_zero(context)) {
-		new_profile->context = switch_core_session_strdup(session, context);
+		new_profile->context = switch_core_strdup(new_profile->pool, context);
 	}
 
-	if (!(dpstr = switch_core_session_strdup(session, new_profile->dialplan))) {
-		abort();
-	}
+	dpstr = switch_core_session_strdup(session, new_profile->dialplan);
 
 	argc = switch_separate_string(dpstr, ',', dp, (sizeof(dp) / sizeof(dp[0])));
 	for (x = 0; x < argc; x++) {