Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8948ee3

Browse files
committed
Fix multiple memory leaks in xml_out(). Per report from Matt Magoffin.
1 parent1cd9356 commit8948ee3

File tree

1 file changed

+8
-10
lines changed
  • src/backend/utils/adt

1 file changed

+8
-10
lines changed

‎src/backend/utils/adt/xml.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.76 2008/08/25 22:42:34 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.77 2008/09/16 00:49:41 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -208,22 +208,16 @@ xml_in(PG_FUNCTION_ARGS)
208208
staticchar*
209209
xml_out_internal(xmltype*x,pg_enctarget_encoding)
210210
{
211-
char*str;
212-
size_tlen;
211+
char*str=text_to_cstring((text*)x);
213212

214213
#ifdefUSE_LIBXML
214+
size_tlen=strlen(str);
215215
xmlChar*version;
216-
xmlChar*encoding;
217216
intstandalone;
218217
intres_code;
219-
#endif
220-
221-
str=text_to_cstring((text*)x);
222-
len=strlen(str);
223218

224-
#ifdefUSE_LIBXML
225219
if ((res_code=parse_xml_decl((xmlChar*)str,
226-
&len,&version,&encoding,&standalone))==0)
220+
&len,&version,NULL,&standalone))==0)
227221
{
228222
StringInfoDatabuf;
229223

@@ -241,6 +235,10 @@ xml_out_internal(xmltype *x, pg_enc target_encoding)
241235
}
242236
appendStringInfoString(&buf,str+len);
243237

238+
if (version)
239+
xmlFree(version);
240+
pfree(str);
241+
244242
returnbuf.data;
245243
}
246244

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp