Make woomera_printf() a little more robust (Klocwork #530 related)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8505 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Stefan Knoblich 2008-05-21 19:54:23 +00:00
parent e78499ef36
commit 6820f1a4cf
1 changed files with 6 additions and 5 deletions

View File

@ -471,7 +471,7 @@ static void tech_destroy(private_object * tech_pvt)
static void woomera_printf(woomera_profile * profile, switch_socket_t * socket, char *fmt, ...)
{
char *stuff;
char *stuff = NULL;
size_t res = 0, len = 0;
va_list ap;
@ -479,13 +479,13 @@ static void woomera_printf(woomera_profile * profile, switch_socket_t * socket,
#ifndef vasprintf
stuff = (char *) malloc(10240);
switch_assert(stuff);
vsnprintf(stuff, 10240, fmt, ap);
res = vsnprintf(stuff, 10240, fmt, ap);
#else
res = vasprintf(&stuff, fmt, ap);
switch_assert(stuff);
#endif
va_end(ap);
if (res == -1) {
if (res < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Out of memory\n");
} else {
if (profile && globals.debug) {
@ -494,10 +494,11 @@ static void woomera_printf(woomera_profile * profile, switch_socket_t * socket,
}
len = strlen(stuff);
switch_socket_send(socket, stuff, &len);
free(stuff);
}
if (stuff) {
free(stuff);
}
}
static char *woomera_message_header(woomera_message * wmsg, char *key)