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:
parent
e78499ef36
commit
6820f1a4cf
|
@ -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, ...)
|
static void woomera_printf(woomera_profile * profile, switch_socket_t * socket, char *fmt, ...)
|
||||||
{
|
{
|
||||||
char *stuff;
|
char *stuff = NULL;
|
||||||
size_t res = 0, len = 0;
|
size_t res = 0, len = 0;
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -479,13 +479,13 @@ static void woomera_printf(woomera_profile * profile, switch_socket_t * socket,
|
||||||
#ifndef vasprintf
|
#ifndef vasprintf
|
||||||
stuff = (char *) malloc(10240);
|
stuff = (char *) malloc(10240);
|
||||||
switch_assert(stuff);
|
switch_assert(stuff);
|
||||||
vsnprintf(stuff, 10240, fmt, ap);
|
res = vsnprintf(stuff, 10240, fmt, ap);
|
||||||
#else
|
#else
|
||||||
res = vasprintf(&stuff, fmt, ap);
|
res = vasprintf(&stuff, fmt, ap);
|
||||||
switch_assert(stuff);
|
switch_assert(stuff);
|
||||||
#endif
|
#endif
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
if (res == -1) {
|
if (res < 0) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Out of memory\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Out of memory\n");
|
||||||
} else {
|
} else {
|
||||||
if (profile && globals.debug) {
|
if (profile && globals.debug) {
|
||||||
|
@ -494,10 +494,11 @@ static void woomera_printf(woomera_profile * profile, switch_socket_t * socket,
|
||||||
}
|
}
|
||||||
len = strlen(stuff);
|
len = strlen(stuff);
|
||||||
switch_socket_send(socket, stuff, &len);
|
switch_socket_send(socket, stuff, &len);
|
||||||
|
|
||||||
free(stuff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stuff) {
|
||||||
|
free(stuff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *woomera_message_header(woomera_message * wmsg, char *key)
|
static char *woomera_message_header(woomera_message * wmsg, char *key)
|
||||||
|
|
Loading…
Reference in New Issue