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
This commit is contained in:
Michael Jerris 2008-05-16 17:25:43 +00:00
parent efd78441d6
commit 36320b9248

View File

@ -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;
}
}