]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't eval MEM() expressions twice
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 29 Feb 2024 06:09:59 +0000 (00:09 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 29 Feb 2024 06:09:59 +0000 (00:09 -0600)
src/lib/util/debug.h

index 9978d97ff4ef6e3be9e8b224b81feb5248c10451..b17c91913d8f6f27cc1d30e38af1032f4544b0d7 100644 (file)
@@ -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 {