提交 b9be04e6 编写于 作者: T Tatsuo Ishii

Add a crash gurard to pg_encoding_mblen in case of an invalid encoding

given.
上级 23436bd5
/*
* 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)));
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册