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

Commit343a9a2

Browse files
committed
Check return code from strxfrm on Windows since it has a
non-standard way of indicating errors, so we don't try toallocate INT_MAX bytes to store a result in.
1 parent4835df3 commit343a9a2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.233 2007/04/21 21:01:45 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.234 2007/05/05 17:05:48 mha Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -3137,6 +3137,10 @@ convert_string_datum(Datum value, Oid typid)
31373137
* from the second call than the first; thus the Assert must be <= not
31383138
* == as you'd expect. Can't any of these people program their way
31393139
* out of a paper bag?
3140+
*
3141+
* XXX: strxfrm doesn't support UTF-8 encoding on Win32, it can return
3142+
* bogus data or set an error. This is not really a problem unless it
3143+
* crashes since it will only give an estimation error and nothing fatal.
31403144
*/
31413145
#if_MSC_VER==1400/* VS.Net 2005 */
31423146

@@ -3151,6 +3155,15 @@ convert_string_datum(Datum value, Oid typid)
31513155
}
31523156
#else
31533157
xfrmlen=strxfrm(NULL,val,0);
3158+
#endif
3159+
#ifdefWIN32
3160+
/*
3161+
* On Windows, strxfrm returns INT_MAX when an error occurs. Instead of
3162+
* trying to allocate this much memory (and fail), just return the
3163+
* original string unmodified as if we were in the C locale.
3164+
*/
3165+
if (xfrmlen==INT_MAX)
3166+
returnval;
31543167
#endif
31553168
xfrmstr= (char*)palloc(xfrmlen+1);
31563169
xfrmlen2=strxfrm(xfrmstr,val,xfrmlen+1);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp