Skip to content

Commit 3245a2a

Browse files
peffgitster
authored andcommitted
http-push: free xml_ctx.cdata after use
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a152809 commit 3245a2a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

http-push.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
913913
result = XML_Parse(parser, in_buffer.buf,
914914
in_buffer.len, 1);
915915
free(ctx.name);
916+
free(ctx.cdata);
916917
if (result != XML_STATUS_OK) {
917918
fprintf(stderr, "XML error: %s\n",
918919
XML_ErrorString(
@@ -1170,6 +1171,7 @@ static void remote_ls(const char *path, int flags,
11701171
result = XML_Parse(parser, in_buffer.buf,
11711172
in_buffer.len, 1);
11721173
free(ctx.name);
1174+
free(ctx.cdata);
11731175

11741176
if (result != XML_STATUS_OK) {
11751177
fprintf(stderr, "XML error: %s\n",

0 commit comments

Comments
 (0)