summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-03-12 00:54:04 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-03-12 00:54:04 +0000
commitaff86a81b5dc66715158db48f0aae5c5b7dc36a5 (patch)
treea162515e3b26db3c27b93837d6b340432a67720c
parentcb5a81b54681a9717880b3c45408a80a834eafa1 (diff)
downloadpostgresql-aff86a81b5dc66715158db48f0aae5c5b7dc36a5.tar.gz
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.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index 6955f0bad5..c821fad3a2 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.69.2.3 2009/01/13 15:28:42 alvherre Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.69.2.4 2009/03/12 00:54:04 tgl Exp $
*
*
* Portions Copyright (c) 1999-2003, PostgreSQL Global Development Group
@@ -347,7 +347,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;