Skip to content

Commit 6dee4ac

Browse files
committed
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...
1 parent d11d8d0 commit 6dee4ac

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/backend/utils/adt/formatting.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -----------------------------------------------------------------------
22
* formatting.c
33
*
4-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.8.2.1 2000/10/19 18:39:03 tgl Exp $
4+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.8.2.2 2000/10/22 19:19:42 tgl Exp $
55
*
66
*
77
* Portions Copyright (c) 1999-2000, PostgreSQL, Inc
@@ -4006,6 +4006,9 @@ numeric_to_char(Numeric value, text *fmt)
40064006
*p;
40074007
Numeric x = NULL;
40084008

4009+
if (!value)
4010+
return textin("");
4011+
40094012
NUM_TOCHAR_prepare;
40104013

40114014
/* ----------
@@ -4089,7 +4092,7 @@ int4_to_char(int32 value, text *fmt)
40894092
plen = 0,
40904093
sign = 0;
40914094
char *numstr,
4092-
*orgnum;
4095+
*orgnum;
40934096

40944097
NUM_TOCHAR_prepare;
40954098

@@ -4170,6 +4173,9 @@ int8_to_char(int64 *value, text *fmt)
41704173
char *numstr,
41714174
*orgnum;
41724175

4176+
if (!value)
4177+
return textin("");
4178+
41734179
NUM_TOCHAR_prepare;
41744180

41754181
/* ----------
@@ -4252,6 +4258,9 @@ float4_to_char(float32 value, text *fmt)
42524258
*orgnum,
42534259
*p;
42544260

4261+
if (!value)
4262+
return textin("");
4263+
42554264
NUM_TOCHAR_prepare;
42564265

42574266
if (IS_ROMAN(&Num))
@@ -4330,6 +4339,9 @@ float8_to_char(float64 value, text *fmt)
43304339
*orgnum,
43314340
*p;
43324341

4342+
if (!value)
4343+
return textin("");
4344+
43334345
NUM_TOCHAR_prepare;
43344346

43354347
if (IS_ROMAN(&Num))

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