diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-03-12 00:53:32 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-03-12 00:53:32 +0000 |
commit | abc48bedc274e1ead6f1e7ad45b48fae0941dc95 (patch) | |
tree | 55bda68c26ca66aebfd9f9ff78db3403188a8187 | |
parent | 9a1dd6ed4bb9d7eee25defff149e93cc9e76b109 (diff) | |
download | postgresql-abc48bedc274e1ead6f1e7ad45b48fae0941dc95.tar.gz postgresql-abc48bedc274e1ead6f1e7ad45b48fae0941dc95.zip |
Fix core dump due to null-pointer dereference in to_char() when datetime
format codes are misapplied to a numeric argument. (The code still produces
a pretty bogus error message in such cases, but I'll settle for stopping the
crash for now.) Per bug #4700 from Sergey Burladyan.
Problem exists in all supported branches, so patch all the way back.
In HEAD, also clean up some ugly coding in the nearby cache management
code.
-rw-r--r-- | src/backend/utils/adt/formatting.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 02b2a905ef4..1638e27d60b 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- * formatting.c * - * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.137 2008/01/01 19:45:52 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.137.2.1 2009/03/12 00:53:32 tgl Exp $ * * * Portions Copyright (c) 1999-2008, PostgreSQL Global Development Group @@ -357,7 +357,7 @@ static int DCHCounter = 0; /* global cache for --- number part */ static NUMCacheEntry NUMCache[NUM_CACHE_FIELDS + 1]; -static NUMCacheEntry *last_NUMCacheEntry; +static NUMCacheEntry *last_NUMCacheEntry = NUMCache + 0; static int n_NUMCache = 0; /* number of entries */ static int NUMCounter = 0; |