mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Add a crash gurard to pg_encoding_mblen in case of an invalid encoding
given.
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* conversion functions between pg_wchar and multi-byte streams.
|
* conversion functions between pg_wchar and multi-byte streams.
|
||||||
* Tatsuo Ishii
|
* 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
|
* WIN1250 client encoding updated by Pavel Behal
|
||||||
*
|
*
|
||||||
@ -502,5 +502,5 @@ pg_mic_mblen(const unsigned char *mbstr)
|
|||||||
int
|
int
|
||||||
pg_encoding_mblen(int encoding, const unsigned char *mbstr)
|
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)));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user