When we ask libexpat to parse XML data, we sometimes set xml_cdata as a
CharacterDataHandler callback. This fills in an allocated string in the
xml_ctx struct which we never free, causing a leak.
I won't pretend to understand the purpose of the field, but it looks
like it is used by other callbacks during the parse. At any rate, we
never look at it again after XML_Parse() returns, so we should be OK to
free() it then.
This fixes several leaks triggered by t5540.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
result = XML_Parse(parser, in_buffer.buf,
in_buffer.len, 1);
free(ctx.name);
+ free(ctx.cdata);
if (result != XML_STATUS_OK) {
fprintf(stderr, "XML error: %s\n",
XML_ErrorString(
result = XML_Parse(parser, in_buffer.buf,
in_buffer.len, 1);
free(ctx.name);
+ free(ctx.cdata);
if (result != XML_STATUS_OK) {
fprintf(stderr, "XML error: %s\n",