aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2001-04-19 02:34:35 +0000
committerTatsuo Ishii <ishii@postgresql.org>2001-04-19 02:34:35 +0000
commitb9be04e63dcb0dca5c67139c58dd5129acaf7c21 (patch)
treeaaebd6de7e9b6499e9c47c2c18c4b609712a7511 /src
parent23436bd530b296f8c56b8b73853b3f010898165f (diff)
downloadpostgresql-b9be04e63dcb0dca5c67139c58dd5129acaf7c21.tar.gz
postgresql-b9be04e63dcb0dca5c67139c58dd5129acaf7c21.zip
Add a crash gurard to pg_encoding_mblen in case of an invalid encoding
given.
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/mb/wchar.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c
index f3d91e963f3..43371f9477a 100644
--- a/src/backend/utils/mb/wchar.c
+++ b/src/backend/utils/mb/wchar.c
@@ -1,7 +1,7 @@
/*
* conversion functions between pg_wchar and multi-byte streams.
* Tatsuo Ishii
- * $Id: wchar.c,v 1.17 2001/03/22 04:00:05 momjian Exp $
+ * $Id: wchar.c,v 1.18 2001/04/19 02:34:35 ishii Exp $
*
* WIN1250 client encoding updated by Pavel Behal
*
@@ -502,5 +502,5 @@ pg_mic_mblen(const unsigned char *mbstr)
int
pg_encoding_mblen(int encoding, const unsigned char *mbstr)
{
- return ((*pg_wchar_table[encoding].mblen) (mbstr));
+ return( (encoding >= 0 && encoding < sizeof(pg_wchar_table)/sizeof(pg_wchar_tbl))? ((*pg_wchar_table[encoding].mblen) (mbstr)) : ((*pg_wchar_table[SQL_ASCII].mblen) (mbstr)));
}