Skip to content

Commit

Permalink
Fix XML parser leaks in http-push
Browse files Browse the repository at this point in the history
XML_Parser were never freed. While at it, move the parser initialization to
right before it is needed.

Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Mike Hommey authored and Junio C Hamano committed Dec 12, 2007
1 parent 03b69c7 commit 472b257
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions http-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -1275,8 +1275,6 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
char *ep;
char timeout_header[25];
struct remote_lock *lock = NULL;
XML_Parser parser = XML_ParserCreate(NULL);
enum XML_Status result;
struct curl_slist *dav_headers = NULL;
struct xml_ctx ctx;

Expand Down Expand Up @@ -1345,6 +1343,8 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
if (start_active_slot(slot)) {
run_active_slot(slot);
if (results.curl_result == CURLE_OK) {
XML_Parser parser = XML_ParserCreate(NULL);
enum XML_Status result;
ctx.name = xcalloc(10, 1);
ctx.len = 0;
ctx.cdata = NULL;
Expand All @@ -1363,6 +1363,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
XML_GetErrorCode(parser)));
lock->timeout = -1;
}
XML_ParserFree(parser);
}
} else {
fprintf(stderr, "Unable to start LOCK request\n");
Expand Down Expand Up @@ -1525,8 +1526,6 @@ static void remote_ls(const char *path, int flags,
struct buffer out_buffer;
char *in_data;
char *out_data;
XML_Parser parser = XML_ParserCreate(NULL);
enum XML_Status result;
struct curl_slist *dav_headers = NULL;
struct xml_ctx ctx;
struct remote_ls_ctx ls;
Expand Down Expand Up @@ -1569,6 +1568,8 @@ static void remote_ls(const char *path, int flags,
if (start_active_slot(slot)) {
run_active_slot(slot);
if (results.curl_result == CURLE_OK) {
XML_Parser parser = XML_ParserCreate(NULL);
enum XML_Status result;
ctx.name = xcalloc(10, 1);
ctx.len = 0;
ctx.cdata = NULL;
Expand All @@ -1587,6 +1588,7 @@ static void remote_ls(const char *path, int flags,
XML_ErrorString(
XML_GetErrorCode(parser)));
}
XML_ParserFree(parser);
}
} else {
fprintf(stderr, "Unable to start PROPFIND request\n");
Expand Down Expand Up @@ -1620,8 +1622,6 @@ static int locking_available(void)
struct buffer out_buffer;
char *in_data;
char *out_data;
XML_Parser parser = XML_ParserCreate(NULL);
enum XML_Status result;
struct curl_slist *dav_headers = NULL;
struct xml_ctx ctx;
int lock_flags = 0;
Expand Down Expand Up @@ -1658,6 +1658,8 @@ static int locking_available(void)
if (start_active_slot(slot)) {
run_active_slot(slot);
if (results.curl_result == CURLE_OK) {
XML_Parser parser = XML_ParserCreate(NULL);
enum XML_Status result;
ctx.name = xcalloc(10, 1);
ctx.len = 0;
ctx.cdata = NULL;
Expand All @@ -1676,6 +1678,7 @@ static int locking_available(void)
XML_GetErrorCode(parser)));
lock_flags = 0;
}
XML_ParserFree(parser);
}
} else {
fprintf(stderr, "Unable to start PROPFIND request\n");
Expand Down

0 comments on commit 472b257

Please sign in to comment.