From: Arran Cudbard-Bell Date: Thu, 29 Feb 2024 06:09:59 +0000 (-0600) Subject: Don't eval MEM() expressions twice X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9afa0f2c0f1fc003e2bcd66036e4b24b46309f5e;p=thirdparty%2Ffreeradius-server.git Don't eval MEM() expressions twice --- diff --git a/src/lib/util/debug.h b/src/lib/util/debug.h index 9978d97ff4e..b17c91913d8 100644 --- a/src/lib/util/debug.h +++ b/src/lib/util/debug.h @@ -32,7 +32,8 @@ extern "C" { #ifdef NO_ASSERT # define MEM(x) error "Use of MEM() not allowed in this source file. Deal with memory allocation failure gracefully" #else -# define MEM(x) do { if (!(x)) { fr_cond_assert_msg((x), "OUT OF MEMORY"); _fr_exit(__FILE__, __LINE__, EXIT_FAILURE, true); } } while (0) +/* Short circuit condition to prevent duplicate evaluation */ +# define MEM(x) do { if (!(x)) { fr_cond_assert_msg(0 && (x), "OUT OF MEMORY"); _fr_exit(__FILE__, __LINE__, EXIT_FAILURE, true); } } while (0) #endif typedef enum {