Skip to content

Commit 1d18adb

Browse files
Charlie Tonneslanmichael-grunder
authored andcommitted
fix: add NULL check for c->funcs before dereferencing in redisReconnect
redisReconnect dereferences c->funcs->free_privctx without checking if c->funcs is NULL, even though the very next block (line 780) correctly guards c->funcs before accessing c->funcs->close. This can cause a NULL pointer dereference crash if redisReconnect is called on a context where funcs has not been set. Fixes #1315
1 parent e834b57 commit 1d18adb

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

hiredis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ int redisReconnect(redisContext *c) {
772772
c->err = 0;
773773
memset(c->errstr, '\0', strlen(c->errstr));
774774

775-
if (c->privctx && c->funcs->free_privctx) {
775+
if (c->privctx && c->funcs && c->funcs->free_privctx) {
776776
c->funcs->free_privctx(c->privctx);
777777
c->privctx = NULL;
778778
}

0 commit comments

Comments
 (0)