From a560a9f827527d01e81d81547d2ced3f707cbb01 Mon Sep 17 00:00:00 2001 From: davidmatson Date: Tue, 20 Sep 2022 15:18:28 -0700 Subject: [PATCH] Fix OutputFileRedirector destructor ordering. --- src/catch2/internal/catch_output_redirect.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/catch2/internal/catch_output_redirect.cpp b/src/catch2/internal/catch_output_redirect.cpp index aa339b16..3686636b 100644 --- a/src/catch2/internal/catch_output_redirect.cpp +++ b/src/catch2/internal/catch_output_redirect.cpp @@ -228,16 +228,16 @@ namespace Catch { } OutputFileRedirector::~OutputFileRedirector() noexcept { - if ( m_readThread.joinable() ) { - m_readThread.join(); - } - fflush_or_throw( m_file ); // std::terminate on failure (due to noexcept) // Restore the original stdout or stderr file descriptor. dup2_or_throw( m_previous.get(), m_fd ); // std::terminate on failure (due to noexcept) + + if ( m_readThread.joinable() ) { + m_readThread.join(); + } } OutputRedirect::OutputRedirect( std::string& output, std::string& error ):