*** pgsql/src/backend/utils/adt/xml.c 2008/10/09 15:49:10 1.68.2.5 --- pgsql/src/backend/utils/adt/xml.c 2008/11/10 18:02:27 1.68.2.6 *************** *** 7,13 **** * 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.68.2.4 2008/09/16 00:49:49 tgl Exp $ * *------------------------------------------------------------------------- */ --- 7,13 ---- * 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.68.2.5 2008/10/09 15:49:10 tgl Exp $ * *------------------------------------------------------------------------- */ *************** sqlchar_to_unicode(char *s) *** 1447,1453 **** GetDatabaseEncoding(), PG_UTF8); ! pg_encoding_mb2wchar_with_len(PG_UTF8, utf8string, ret, pg_mblen(s)); return ret[0]; } --- 1447,1457 ---- GetDatabaseEncoding(), PG_UTF8); ! pg_encoding_mb2wchar_with_len(PG_UTF8, utf8string, ret, ! pg_encoding_mblen(PG_UTF8, utf8string)); ! ! if (utf8string != s) ! pfree(utf8string); return ret[0]; } *************** map_sql_identifier_to_xml_name(char *ide *** 1537,1543 **** static char * unicode_to_sqlchar(pg_wchar c) { ! static unsigned char utf8string[5]; /* need trailing zero */ if (c <= 0x7F) { --- 1541,1550 ---- static char * unicode_to_sqlchar(pg_wchar c) { ! unsigned char utf8string[5]; /* need room for trailing zero */ ! char *result; ! ! memset(utf8string, 0, sizeof(utf8string)); if (c <= 0x7F) { *************** unicode_to_sqlchar(pg_wchar c) *** 1562,1571 **** utf8string[3] = 0x80 | (c & 0x3F); } ! return (char *) pg_do_encoding_conversion(utf8string, ! pg_mblen((char *) utf8string), ! PG_UTF8, ! GetDatabaseEncoding()); } --- 1569,1583 ---- utf8string[3] = 0x80 | (c & 0x3F); } ! result = (char *) pg_do_encoding_conversion(utf8string, ! pg_encoding_mblen(PG_UTF8, ! (char *) utf8string), ! PG_UTF8, ! GetDatabaseEncoding()); ! /* if pg_do_encoding_conversion didn't strdup, we must */ ! if (result == (char *) utf8string) ! result = pstrdup(result); ! return result; }