aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2011-04-01 19:58:36 +0200
committerMagnus Hagander <magnus@hagander.net>2011-04-01 20:00:34 +0200
commit7b99cfbe565e1b2193cefff79f2476c8373b7c61 (patch)
treec2f6a988485cf3a896ee3bdb33472e8d3d6a37b4
parenteff933531e7f7d98ba02402c7821b0b7ea8f1d97 (diff)
downloadpostgresql-7b99cfbe565e1b2193cefff79f2476c8373b7c61.tar.gz
postgresql-7b99cfbe565e1b2193cefff79f2476c8373b7c61.zip
Avoid palloc before CurrentMemoryContext is set up on win32
Instead, write the unconverted output - it will be in the wrong encoding, but at least we don't crash. Rushabh Lathia
-rw-r--r--src/backend/utils/error/elog.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index feb0bd51fc9..71aed1e0f1d 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -1658,10 +1658,14 @@ write_console(const char *line, int len)
/*
* WriteConsoleW() will fail of stdout is redirected, so just fall through
* to writing unconverted to the logfile in this case.
+ *
+ * Since we palloc the structure required for conversion, also fall through
+ * to writing unconverted if we have not yet set up CurrentMemoryContext.
*/
if (GetDatabaseEncoding() != GetPlatformEncoding() &&
!in_error_recursion_trouble() &&
- !redirection_done)
+ !redirection_done &&
+ CurrentMemoryContext != NULL)
{
WCHAR *utf16;
int utf16len;