From ac47950238480321862c3a0b66cb01c40af801db Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Tue, 26 Nov 2002 02:22:29 +0000 Subject: [PATCH] Guard against 0 length string encoding conversion case. --- src/backend/utils/mb/mbutils.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index 6179fa9efd..d66444d78d 100644 --- a/src/backend/utils/mb/mbutils.c +++ b/src/backend/utils/mb/mbutils.c @@ -4,7 +4,7 @@ * (currently mule internal code (mic) is used) * Tatsuo Ishii * - * $Header: /cvsroot/pgsql/src/backend/utils/mb/mbutils.c,v 1.36 2002/11/02 18:41:22 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/mbutils.c,v 1.37 2002/11/26 02:22:29 ishii Exp $ */ #include "postgres.h" @@ -165,6 +165,9 @@ pg_do_encoding_conversion(unsigned char *src, int len, if (src_encoding == PG_SQL_ASCII || dest_encoding == PG_SQL_ASCII) return src; + if (len <= 0) + return src; + proc = FindDefaultConversionProc(src_encoding, dest_encoding); if (!OidIsValid(proc)) { @@ -320,6 +323,9 @@ perform_default_encoding_conversion(unsigned char *src, int len, bool is_client_ dest_encoding; FmgrInfo *flinfo; + if (len <= 0) + return src; + if (is_client_to_server) { src_encoding = ClientEncoding->encoding;