]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't evaluate _uctx multiple times in fr_atexit_thread_local
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 5 Jan 2022 17:59:25 +0000 (11:59 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 5 Jan 2022 18:03:23 +0000 (12:03 -0600)
src/lib/util/atexit.h

index 769fe2f3fa6e1c3417412b7d08d86737ade4070e..2f329c67f76a30018cc774954e0598f92a4108e4 100644 (file)
@@ -105,8 +105,9 @@ int _atexit_global(NDEBUG_LOCATION_ARGS fr_atexit_t func, void const *uctx);
  */
 #  define fr_atexit_thread_local(_name, _free, _uctx) \
 do { \
-       _fr_atexit_thread_local(NDEBUG_LOCATION_EXP _free, _uctx); \
-       _name = _uctx; \
+       void *_our_uctx = _uctx; /* stop _uctx being evaluated multiple times, it may be a call to malloc() */ \
+       _fr_atexit_thread_local(NDEBUG_LOCATION_EXP _free, _our_uctx); \
+       _name = _our_uctx; \
 } while (0);
 
 int            _fr_atexit_thread_local(NDEBUG_LOCATION_ARGS