Using assignment inside the assert() macro is a dangerous. In release builds, the entire assert macro is completely deleted by the preprocessor, including the assignment operation. This causes the p variable to remain uninitialized, which causes undefined behavior on subsequent access.
assert((p = lpSeek(lp, r)))
It is recommended to separate the assert check and the assignment operation.
https://github.com/redis/redis/blob/8.0.3/src/listpack.c#L1770
Found by Linux Verification ( linuxtesting.org ) with SVACE. Reporter: Gushchin Egor ( guschin058@yandex.ru )
Comment From: sundb
please take a look at this PR: https://github.com/redis/redis/pull/12539 It avoids the assert being affected by NDEBUG.
Comment From: guschin058
Good.Thanks for the clarification! Then no correction is required.