From: Tom Lane Date: Sun, 22 Oct 2000 19:19:42 +0000 (+0000) Subject: Fix to_char() to avoid coredump on NULL input. Not needed in current X-Git-Tag: REL7_0_3~9 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=6dee4ac84ce6382ce55a51ab519a1e37e00738f1;p=postgresql.git Fix to_char() to avoid coredump on NULL input. Not needed in current sources due to fmgr rewrite, but 7.0.3 can use the patch... --- diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 62369193234..0701b800672 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- * formatting.c * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.8.2.1 2000/10/19 18:39:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.8.2.2 2000/10/22 19:19:42 tgl Exp $ * * * Portions Copyright (c) 1999-2000, PostgreSQL, Inc @@ -4006,6 +4006,9 @@ numeric_to_char(Numeric value, text *fmt) *p; Numeric x = NULL; + if (!value) + return textin(""); + NUM_TOCHAR_prepare; /* ---------- @@ -4089,7 +4092,7 @@ int4_to_char(int32 value, text *fmt) plen = 0, sign = 0; char *numstr, - *orgnum; + *orgnum; NUM_TOCHAR_prepare; @@ -4170,6 +4173,9 @@ int8_to_char(int64 *value, text *fmt) char *numstr, *orgnum; + if (!value) + return textin(""); + NUM_TOCHAR_prepare; /* ---------- @@ -4252,6 +4258,9 @@ float4_to_char(float32 value, text *fmt) *orgnum, *p; + if (!value) + return textin(""); + NUM_TOCHAR_prepare; if (IS_ROMAN(&Num)) @@ -4330,6 +4339,9 @@ float8_to_char(float64 value, text *fmt) *orgnum, *p; + if (!value) + return textin(""); + NUM_TOCHAR_prepare; if (IS_ROMAN(&Num))