timeout = atoi(argv[6]);
}
- if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
+ if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS || !caller_session) {
if (machine) {
stream->write_function(stream, "-ERR %s\n", switch_channel_cause2str(cause));
} else {
stream->write_function(stream, "+OK Created Session: %s\n", switch_core_session_get_uuid(caller_session));
}
- if (caller_session) {
- switch_core_session_rwunlock(caller_session);
- }
+ switch_core_session_rwunlock(caller_session);
done:
switch_safe_free(mycmd);
char *reply, *freply = NULL;
switch_event_t *event;
char *arg;
+ switch_memory_pool_t *pool;
+
+ if (!job) return NULL;
+
+ pool = job->pool;
SWITCH_STANDARD_STREAM(stream);
switch_safe_free(stream.data);
switch_safe_free(freply);
- if (job) {
- switch_memory_pool_t *pool = job->pool;
- job = NULL;
- switch_core_destroy_memory_pool(&pool);
- pool = NULL;
- }
+ job = NULL;
+ switch_core_destroy_memory_pool(&pool);
+ pool = NULL;
return NULL;
}
switch_xml_free(xml);
} else {
stream->write_function(stream, "-ERR Unable to create xml!\n");
+ switch_event_destroy(&event);
switch_core_session_rwunlock(psession);
goto done;
}
switch_event_destroy(&event);
free(buf);
} else {
- abort();
+ stream->write_function(stream, "-ERR Allocation error\n");
}
switch_core_session_rwunlock(psession);