From: Tom Lane Date: Tue, 16 Sep 2008 00:49:49 +0000 (+0000) Subject: Fix multiple memory leaks in xml_out(). Per report from Matt Magoffin. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=79edf770bc984a6007200fde9be778b68e41c86c;p=users%2Fbernd%2Fpostgres.git Fix multiple memory leaks in xml_out(). Per report from Matt Magoffin. --- diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index ca2c4a149e..69f515a3b2 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -208,7 +208,6 @@ xml_out_internal(xmltype *x, pg_enc target_encoding) #ifdef USE_LIBXML xmlChar *version; - xmlChar *encoding; int standalone; int res_code; #endif @@ -220,7 +219,7 @@ xml_out_internal(xmltype *x, pg_enc target_encoding) #ifdef USE_LIBXML if ((res_code = parse_xml_decl((xmlChar *) str, - &len, &version, &encoding, &standalone)) == 0) + &len, &version, NULL, &standalone)) == 0) { StringInfoData buf; @@ -238,6 +237,10 @@ xml_out_internal(xmltype *x, pg_enc target_encoding) } appendStringInfoString(&buf, str + len); + if (version) + xmlFree(version); + pfree(str); + return buf.data; }