Fix XML parser leaks in http-push
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>
Mike Hommey committed
Dec 11, 2007 at 23:50 UTC
472b25709900723a35b404456ae8e28bfc446932
1 file changed
+9
-6
http-push.c
+9
-6
@@ -1275,8 +1275,6 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
1275
char *ep;
1276
char timeout_header[25];
1277
struct remote_lock *lock = NULL;
1278
- XML_Parser parser = XML_ParserCreate(NULL);
1279
- enum XML_Status result;
1278
struct curl_slist *dav_headers = NULL;
1279
struct xml_ctx ctx;
1280
@@ -1345,6 +1343,8 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
1343
if (start_active_slot(slot)) {
1344
run_active_slot(slot);
1345
if (results.curl_result == CURLE_OK) {
1346
+ XML_Parser parser = XML_ParserCreate(NULL);
1347
+ enum XML_Status result;
1348
ctx.name = xcalloc(10, 1);
1349
ctx.len = 0;
1350
ctx.cdata = NULL;
@@ -1363,6 +1363,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
1363
XML_GetErrorCode(parser)));
1364
lock->timeout = -1;
1365
}
1366
+ XML_ParserFree(parser);
1367
}
1368
} else {
1369
fprintf(stderr, "Unable to start LOCK request\n");
@@ -1525,8 +1526,6 @@ static void remote_ls(const char *path, int flags,
1526
struct buffer out_buffer;
1527
char *in_data;
1528
char *out_data;
1528
- XML_Parser parser = XML_ParserCreate(NULL);
1529
- enum XML_Status result;
1529
struct curl_slist *dav_headers = NULL;
1530
struct xml_ctx ctx;
1531
struct remote_ls_ctx ls;
@@ -1569,6 +1568,8 @@ static void remote_ls(const char *path, int flags,
1568
if (start_active_slot(slot)) {
1569
run_active_slot(slot);
1570
if (results.curl_result == CURLE_OK) {
1571
+ XML_Parser parser = XML_ParserCreate(NULL);
1572
+ enum XML_Status result;
1573
ctx.name = xcalloc(10, 1);
1574
ctx.len = 0;
1575
ctx.cdata = NULL;
@@ -1587,6 +1588,7 @@ static void remote_ls(const char *path, int flags,
1588
XML_ErrorString(
1589
XML_GetErrorCode(parser)));
1590
}
1591
+ XML_ParserFree(parser);
1592
}
1593
} else {
1594
fprintf(stderr, "Unable to start PROPFIND request\n");
@@ -1620,8 +1622,6 @@ static int locking_available(void)
1622
struct buffer out_buffer;
1623
char *in_data;
1624
char *out_data;
1623
- XML_Parser parser = XML_ParserCreate(NULL);
1624
- enum XML_Status result;
1625
struct curl_slist *dav_headers = NULL;
1626
struct xml_ctx ctx;
1627
int lock_flags = 0;
@@ -1658,6 +1658,8 @@ static int locking_available(void)
1658
if (start_active_slot(slot)) {
1659
run_active_slot(slot);
1660
if (results.curl_result == CURLE_OK) {
1661
+ XML_Parser parser = XML_ParserCreate(NULL);
1662
+ enum XML_Status result;
1663
ctx.name = xcalloc(10, 1);
1664
ctx.len = 0;
1665
ctx.cdata = NULL;
@@ -1676,6 +1678,7 @@ static int locking_available(void)
1678
XML_GetErrorCode(parser)));
1679
lock_flags = 0;
1680
}
1681
+ XML_ParserFree(parser);
1682
}
1683
} else {
1684
fprintf(stderr, "Unable to start PROPFIND request\n");