Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Avoid palloc before CurrentMemoryContext is set up on win32
authorMagnus Hagander <magnus@hagander.net>
Fri, 1 Apr 2011 17:58:36 +0000 (19:58 +0200)
committerMagnus Hagander <magnus@hagander.net>
Fri, 1 Apr 2011 17:59:44 +0000 (19:59 +0200)
Instead, write the unconverted output - it will be in the wrong
encoding, but at least we don't crash.

Rushabh Lathia

src/backend/utils/error/elog.c

index 5679d5b9c1a98966e52459abb5cf5bbfc34c2601..e7bc046d87007d40431d262a9a0e80aa6edac12f 100644 (file)
@@ -1668,10 +1668,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;