From 23bab9e69939df516afae1e13900f90af1cc43b3 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Mon, 12 Jan 2026 21:14:22 +0000 Subject: [PATCH] Wrap wxCHECK macro inside a do{}while construct to protect it Before, it is just a bare if statement, which could pose issues if used as the only statement in a single-line control flow construct, where the else clause could get associated with the wrong if statement. Closes #26096. --- include/wx/debug.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/wx/debug.h b/include/wx/debug.h index 42adfbee5e..eb2a73a849 100644 --- a/include/wx/debug.h +++ b/include/wx/debug.h @@ -354,6 +354,7 @@ extern void WXDLLIMPEXP_BASE wxAbort(); // the generic macro: takes the condition to check, the statement to be executed // in case the condition is false and the message to pass to the assert handler #define wxCHECK2_MSG(cond, op, msg) \ + wxSTATEMENT_MACRO_BEGIN \ if ( cond ) \ {} \ else \ @@ -361,7 +362,7 @@ extern void WXDLLIMPEXP_BASE wxAbort(); wxFAIL_COND_MSG(#cond, msg); \ op; \ } \ - struct wxMAKE_UNIQUE_NAME(wxDummyCheckStruct) /* to force a semicolon */ + wxSTATEMENT_MACRO_END // check which returns with the specified return code if the condition fails #define wxCHECK_MSG(cond, rc, msg) wxCHECK2_MSG(cond, return rc, msg)