Fixed a crash when redirecting stdout.