diff options
| author | Jeff King <peff@peff.net> | 2024-09-24 18:09:54 -0400 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-09-25 10:24:57 -0700 |
| commit | 3245a2ade5ee0ff3e5fad7bd96ad0a630c590e82 (patch) | |
| tree | 7da781ec3f8ec68157f08cb855198b8ec47d872a /http-push.c | |
| parent | http-push: free remote_ls_ctx.dentry_name (diff) | |
| download | git-3245a2ade5ee0ff3e5fad7bd96ad0a630c590e82.tar.gz git-3245a2ade5ee0ff3e5fad7bd96ad0a630c590e82.zip | |
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http-push.c')
| -rw-r--r-- | http-push.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/http-push.c b/http-push.c index 2e1c6851bb..1146d7c6fe 100644 --- a/http-push.c +++ b/http-push.c @@ -913,6 +913,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout) 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( @@ -1170,6 +1171,7 @@ static void remote_ls(const char *path, int flags, 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", |
