Index: src/backend/utils/adt/oracle_compat.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/utils/adt/oracle_compat.c,v
retrieving revision 1.38
diff -c -r1.38 oracle_compat.c
*** src/backend/utils/adt/oracle_compat.c	20 Jun 2002 20:51:45 -0000	1.38
--- src/backend/utils/adt/oracle_compat.c	20 Aug 2002 21:04:07 -0000
***************
*** 199,204 ****
--- 199,209 ----
  
  #ifdef MULTIBYTE
  	bytelen = pg_database_encoding_max_length() * len;
+ 
+ 	/* check for integer overflow */
+ 	if (len != 0 && bytelen / pg_database_encoding_max_length() != len)
+ 		elog(ERROR, "Requested length too large");
+ 
  	ret = (text *) palloc(VARHDRSZ + bytelen);
  #else
  	ret = (text *) palloc(VARHDRSZ + len);
***************
*** 310,315 ****
--- 315,325 ----
  
  #ifdef MULTIBYTE
  	bytelen = pg_database_encoding_max_length() * len;
+ 
+ 	/* Check for integer overflow */
+ 	if (len != 0 && bytelen / pg_database_encoding_max_length() != len)
+ 		elog(ERROR, "Requested length too large");
+ 
  	ret = (text *) palloc(VARHDRSZ + bytelen);
  #else
  	ret = (text *) palloc(VARHDRSZ + len);
