]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: Cast to volatile int * instead of int *.
authorOlivier Houchard <cognet@ci0.org>
Sat, 15 Dec 2018 23:58:28 +0000 (00:58 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 16 Dec 2018 07:15:16 +0000 (08:15 +0100)
When using DEBUG_MEMORY_POOLS, when we want to crash, instead of using
*(int *)0 = 0, use *(volatile int *)0 = 0, or clang will just translate it
to a nop, instead of dereferencing 0.

include/common/memory.h

index 7e7d30b86fe32859bcbcc2361f169a3bb8974cfa..9c54422a2f61833492f818173e78a343dd7aa3e2 100644 (file)
@@ -475,7 +475,7 @@ static inline void pool_free(struct pool_head *pool, void *ptr)
 #ifdef DEBUG_MEMORY_POOLS
                /* we'll get late corruption if we refill to the wrong pool or double-free */
                if (*POOL_LINK(pool, ptr) != (void *)pool)
-                       *(int *)0 = 0;
+                       *(volatile int *)0 = 0;
 #endif
 
 #ifndef DEBUG_UAF /* normal pool behaviour */