From 8f95edc9c434ffcea6f0dabbfeb221aca8fdfbc5 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Fri, 25 Apr 2025 15:48:34 +0200 Subject: [PATCH] MT#59962 DRedisConnection: ensure redis_context isn't NULL When dereferencing it (after creating a new context before) make sure it's not NULL even when just checking for a connection error, as it might still be NULL and hence will just seg.fault in this case. Fixes: Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking this->redis_context suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Change-Id: I67f88f1dfccef66751298b1c26e85efba0458c1f --- apps/dsm/mods/mod_redis/DRedisConnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dsm/mods/mod_redis/DRedisConnection.cpp b/apps/dsm/mods/mod_redis/DRedisConnection.cpp index adb2428e..acd74fde 100644 --- a/apps/dsm/mods/mod_redis/DRedisConnection.cpp +++ b/apps/dsm/mods/mod_redis/DRedisConnection.cpp @@ -63,7 +63,7 @@ bool DRedisConnection::connect() cfg.tv_timeout); } - if (redis_context->err) { + if (redis_context != NULL && redis_context->err) { ERROR("REDIS Connection error: %s\n", redis_context->errstr); disconnect(); return false;