Commit b9be04e6 authored by Tatsuo Ishii's avatar Tatsuo Ishii

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

given.
parent 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% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment