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.
This commit is contained in:
Ian McInerney
2026-01-12 21:14:22 +00:00
committed by Vadim Zeitlin
parent 8ada351adf
commit 23bab9e699

View File

@@ -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)