mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Fix multiple memory leaks in xml_out(). Per report from Matt Magoffin.
This commit is contained in:
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.76 2008/08/25 22:42:34 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.77 2008/09/16 00:49:41 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -208,22 +208,16 @@ xml_in(PG_FUNCTION_ARGS)
|
|||||||
static char *
|
static char *
|
||||||
xml_out_internal(xmltype *x, pg_enc target_encoding)
|
xml_out_internal(xmltype *x, pg_enc target_encoding)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str = text_to_cstring((text *) x);
|
||||||
size_t len;
|
|
||||||
|
|
||||||
#ifdef USE_LIBXML
|
#ifdef USE_LIBXML
|
||||||
|
size_t len = strlen(str);
|
||||||
xmlChar *version;
|
xmlChar *version;
|
||||||
xmlChar *encoding;
|
|
||||||
int standalone;
|
int standalone;
|
||||||
int res_code;
|
int res_code;
|
||||||
#endif
|
|
||||||
|
|
||||||
str = text_to_cstring((text *) x);
|
|
||||||
len = strlen(str);
|
|
||||||
|
|
||||||
#ifdef USE_LIBXML
|
|
||||||
if ((res_code = parse_xml_decl((xmlChar *) str,
|
if ((res_code = parse_xml_decl((xmlChar *) str,
|
||||||
&len, &version, &encoding, &standalone)) == 0)
|
&len, &version, NULL, &standalone)) == 0)
|
||||||
{
|
{
|
||||||
StringInfoData buf;
|
StringInfoData buf;
|
||||||
|
|
||||||
@ -241,6 +235,10 @@ xml_out_internal(xmltype *x, pg_enc target_encoding)
|
|||||||
}
|
}
|
||||||
appendStringInfoString(&buf, str + len);
|
appendStringInfoString(&buf, str + len);
|
||||||
|
|
||||||
|
if (version)
|
||||||
|
xmlFree(version);
|
||||||
|
pfree(str);
|
||||||
|
|
||||||
return buf.data;
|
return buf.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user