Bug 1163452 - Only register stderr if it differs from stdout. r=glandium

Under certain Windows shells, the handle for stderr may be the same as
the handle for stdout.  Avoid crashing in this case.

Differential Revision: https://phabricator.services.mozilla.com/D150517
This commit is contained in:
Nick Alexander 2022-06-29 17:15:45 +00:00
parent 339b9867ca
commit 4170258b2e

View File

@ -465,7 +465,9 @@ void InitPoisonIOInterposer() {
// Stdout and Stderr are OK.
MozillaRegisterDebugFD(1);
MozillaRegisterDebugFD(2);
if (::GetStdHandle(STD_OUTPUT_HANDLE) != ::GetStdHandle(STD_ERROR_HANDLE)) {
MozillaRegisterDebugFD(2);
}
#ifdef MOZ_REPLACE_MALLOC
// The contract with InitDebugFd is that the given registry can be used