Skip to content

Commit 7b99cfb

Browse files
committed
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
1 parent eff9335 commit 7b99cfb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/backend/utils/error/elog.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1658,10 +1658,14 @@ write_console(const char *line, int len)
16581658
/*
16591659
* WriteConsoleW() will fail of stdout is redirected, so just fall through
16601660
* to writing unconverted to the logfile in this case.
1661+
*
1662+
* Since we palloc the structure required for conversion, also fall through
1663+
* to writing unconverted if we have not yet set up CurrentMemoryContext.
16611664
*/
16621665
if (GetDatabaseEncoding() != GetPlatformEncoding() &&
16631666
!in_error_recursion_trouble() &&
1664-
!redirection_done)
1667+
!redirection_done &&
1668+
CurrentMemoryContext != NULL)
16651669
{
16661670
WCHAR *utf16;
16671671
int utf16len;

0 commit comments

Comments
 (0)