Skip to content

Commit d2d52bb

Browse files
committed
xmlGetUTF8Char()'s second argument is both input and output. Fix
uninitialized value, and avoid invoking the function nine separate times in the pg_xmlIsNameChar macro. Should resolve buildfarm failures. Per report from Ben Leslie.
1 parent 58ac0f9 commit d2d52bb

File tree

1 file changed

+9
-5
lines changed
  • src/backend/utils/adt

1 file changed

+9
-5
lines changed

src/backend/utils/adt/xml.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, 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.54 2007/11/09 15:52:51 petere Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.55 2007/11/10 18:51:20 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -998,20 +998,22 @@ xml_init(void)
998998
while (xmlIsBlank_ch(*(p))) (p)++
999999

10001000
/* Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender */
1001-
#define pg_xmlIsNameChar(c) \
1001+
/* Beware of multiple evaluations of argument! */
1002+
#define PG_XMLISNAMECHAR(c) \
10021003
(xmlIsBaseChar_ch(c) || xmlIsIdeographicQ(c) \
10031004
|| xmlIsDigit_ch(c) \
10041005
|| c == '.' || c == '-' || c == '_' || c == ':' \
10051006
|| xmlIsCombiningQ(c) \
10061007
|| xmlIsExtender_ch(c))
10071008

10081009
static int
1009-
parse_xml_decl(const xmlChar *str,size_t *lenp,
1010+
parse_xml_decl(const xmlChar *str, size_t *lenp,
10101011
xmlChar **version, xmlChar **encoding, int *standalone)
10111012
{
10121013
const xmlChar *p;
10131014
const xmlChar *save_p;
10141015
size_t len;
1016+
int utf8char;
10151017
int utf8len;
10161018

10171019
xml_init();
@@ -1028,8 +1030,10 @@ parse_xml_decl(const xmlChar *str,size_t *lenp,
10281030
if (xmlStrncmp(p, (xmlChar *)"<?xml", 5) != 0)
10291031
goto finished;
10301032

1031-
/* This means it's a PI like <?xml-stylesheet ...?>. */
1032-
if (pg_xmlIsNameChar(xmlGetUTF8Char(&p[5], &utf8len)))
1033+
/* if next char is name char, it's a PI like <?xml-stylesheet ...?> */
1034+
utf8len = strlen((const char *) (p+5));
1035+
utf8char = xmlGetUTF8Char(p+5, &utf8len);
1036+
if (PG_XMLISNAMECHAR(utf8char))
10331037
goto finished;
10341038

10351039
p += 5;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy