*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.39 2002/08/22 04:54:20 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.40 2002/08/22 04:55:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#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);
#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);