From 36320b9248b872edee3b780bcedc9e985d4b04a5 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Fri, 16 May 2008 17:25:43 +0000 Subject: [PATCH] handle edgecase leak on platforms without vasprintf. Found by Klockwork (www.klocwork.com) git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8445 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_event.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/switch_event.c b/src/switch_event.c index 423983c298..80552616b5 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -863,11 +863,14 @@ SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const ch ret = vasprintf(&data, fmt, ap); #else data = (char *) malloc(2048); - switch_assert(data); + if (!data) return NULL; ret = vsnprintf(data, 2048, fmt, ap); #endif va_end(ap); if (ret == -1) { +#ifndef HAVE_VASPRINTF + free(data); +#endif return NULL; } }