From 2dda7f7ef6cee66b09fbb1485f796261a1456997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Heusipp?= Date: Tue, 24 Sep 2024 07:51:35 +0000 Subject: [PATCH] [Fix] openmpt123: Set stdin to text mode only after parsing commandline and verifying that we are not supposed to take binary data from stdin. git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@21733 56274372-70c3-4bfc-bfc3-4c3a0b034d27 --- openmpt123/openmpt123.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openmpt123/openmpt123.cpp b/openmpt123/openmpt123.cpp index 8c32ce5817..ba05d385c2 100644 --- a/openmpt123/openmpt123.cpp +++ b/openmpt123/openmpt123.cpp @@ -2184,7 +2184,6 @@ class terminal_ui_guard { static mpt::uint8 main( std::vector args ) { - FILE_mode_guard stdin_text_guard( stdin, FILE_mode::text ); FILE_mode_guard stdout_text_guard( stdout, FILE_mode::text ); FILE_mode_guard stderr_text_guard( stderr, FILE_mode::text ); @@ -2276,7 +2275,8 @@ static mpt::uint8 main( std::vector args ) { [[maybe_unused]] std::optional stdin_guard{ stdin_data ? std::make_optional( stdin, FILE_mode::binary ) : std::nullopt }; [[maybe_unused]] std::optional stdout_guard{ stdout_data ? std::make_optional( stdout, FILE_mode::binary ) : std::nullopt }; - // setup terminal + // setup terminal input + [[maybe_unused]] std::optional stdin_text_guard{ stdin_text ? std::make_optional( stdin, FILE_mode::text ) : std::nullopt }; [[maybe_unused]] std::optional input_guard{ stdin_text && ( flags.mode == Mode::UI ) ? std::make_optional() : std::nullopt }; // choose text output between quiet/stdout/stderr