Skip to content

Commit b9be04e

Browse files
committed
Add a crash gurard to pg_encoding_mblen in case of an invalid encoding
given.
1 parent 23436bd commit b9be04e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/utils/mb/wchar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* conversion functions between pg_wchar and multi-byte streams.
33
* Tatsuo Ishii
4-
* $Id: wchar.c,v 1.17 2001/03/22 04:00:05 momjian Exp $
4+
* $Id: wchar.c,v 1.18 2001/04/19 02:34:35 ishii Exp $
55
*
66
* WIN1250 client encoding updated by Pavel Behal
77
*
@@ -502,5 +502,5 @@ pg_mic_mblen(const unsigned char *mbstr)
502502
int
503503
pg_encoding_mblen(int encoding, const unsigned char *mbstr)
504504
{
505-
return ((*pg_wchar_table[encoding].mblen) (mbstr));
505+
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)));
506506
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy