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