From 6b5e123a1232d325da7057393a59504f006989ec Mon Sep 17 00:00:00 2001 From: offa <8887756+offa@users.noreply.github.com> Date: Wed, 26 Nov 2025 19:26:09 +0100 Subject: [PATCH] Fix potential issues in TestUtil --- test/TestUtil.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/TestUtil.h b/test/TestUtil.h index 1c06523..c4ac55b 100644 --- a/test/TestUtil.h +++ b/test/TestUtil.h @@ -34,8 +34,13 @@ namespace test explicit DisableStream(FILE* handle) : fileDescriptor(dup(streamFd)), fileHandle(handle) { + if (fileDescriptor < 0) + { + throw std::runtime_error{"failed to dup() stream"}; + } fflush(fileHandle); - if (const auto rtn = freopen("NUL", "a", fileHandle); rtn == nullptr) + + if (const auto* rtn = freopen("NUL", "a", fileHandle); rtn == nullptr) { throw std::runtime_error{"failed to redirect stream"}; }