git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix XML parser leaks in http-push
@ 2007-12-11 21:19 Mike Hommey
  2007-12-11 21:19 ` [PATCH 2/2] Fix some memory leaks in various places Mike Hommey
  2007-12-11 22:30 ` [PATCH 1/2 v2] Fix XML parser leaks in http-push Mike Hommey
  0 siblings, 2 replies; 6+ messages in thread
From: Mike Hommey @ 2007-12-11 21:19 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

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>
---
 http-push.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/http-push.c b/http-push.c
index a4a9d1c..f5ba850 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1189,8 +1189,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;
 
@@ -1250,6 +1248,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;
@@ -1268,6 +1268,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");
@@ -1428,8 +1429,6 @@ static void remote_ls(const char *path, int flags,
 	struct slot_results results;
 	struct strbuf in_buffer = STRBUF_INIT;
 	struct buffer out_buffer = { 0, STRBUF_INIT };
-	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;
@@ -1463,6 +1462,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;
@@ -1481,6 +1482,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");
@@ -1512,8 +1514,6 @@ static int locking_available(void)
 	struct slot_results results;
 	struct strbuf in_buffer = STRBUF_INIT;
 	struct buffer out_buffer = { 0, STRBUF_INIT };
-	XML_Parser parser = XML_ParserCreate(NULL);
-	enum XML_Status result;
 	struct curl_slist *dav_headers = NULL;
 	struct xml_ctx ctx;
 	int lock_flags = 0;
@@ -1538,6 +1538,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;
@@ -1556,6 +1558,7 @@ static int locking_available(void)
 						XML_GetErrorCode(parser)));
 				lock_flags = 0;
 			}
+			XML_ParserFree(parser);
 		}
 	} else {
 		fprintf(stderr, "Unable to start PROPFIND request\n");
-- 
1.5.3.7

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-12-11 22:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-11 21:19 [PATCH 1/2] Fix XML parser leaks in http-push Mike Hommey
2007-12-11 21:19 ` [PATCH 2/2] Fix some memory leaks in various places Mike Hommey
2007-12-11 21:59   ` [PATCH 3/2] Fix small memory leaks induced by diff_tree_setup_paths Mike Hommey
2007-12-11 22:30 ` [PATCH 1/2 v2] Fix XML parser leaks in http-push Mike Hommey
2007-12-11 22:36   ` Junio C Hamano
2007-12-11 22:50     ` [PATCH 1/2 for master] " Mike Hommey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).