From 1bbf8706ae6e7a307ac0739d9df51b47832c7d4b Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Sat, 12 Jan 2008 21:14:08 +0000
Subject: [PATCH] It turns out the LIBXML_TEST_VERSION macro calls
 xmlInitParser(). Therefore we must xmlCleanupParser(), or we risk leaving
 behind dangling pointers to whatever memory context is current when
 xml_init() is called.  This seems to fix bug #3860, though we might still
 want the more invasive solution being worked on by Alvaro.

---
 src/backend/utils/adt/xml.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index 622d4e05f7f..411cd6c22ed 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.66 2008/01/12 10:50:03 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.67 2008/01/12 21:14:08 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -958,6 +958,9 @@ xml_init(void)
 		/* Check library compatibility */
 		LIBXML_TEST_VERSION;
 
+		/* The above calls xmlInitParser(); must clean up dangling pointers */
+		xmlCleanupParser();
+
 		first_time = false;
 	}
 	else
-- 
GitLab