Skip to content

Commit

Permalink
Check ptr in listRelease
Browse files Browse the repository at this point in the history
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
  • Loading branch information
bjosv committed Oct 9, 2024
1 parent 972b25f commit d6586c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/adlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ void listRelease(hilist *list) {
unsigned long len;
listNode *current, *next;

if (list == NULL)
return;
current = list->head;
len = list->len;
while (len--) {
Expand Down
19 changes: 5 additions & 14 deletions src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,8 @@ static void freeValkeyClusterNode(valkeyClusterNode *node) {
node->acon->data = NULL;
valkeyAsyncFree(node->acon);
}
if (node->slots != NULL) {
listRelease(node->slots);
}
if (node->slaves != NULL) {
listRelease(node->slaves);
}
listRelease(node->slots);
listRelease(node->slaves);
vk_free(node);
}

Expand Down Expand Up @@ -1314,10 +1310,7 @@ void valkeyClusterFree(valkeyClusterContext *cc) {
vk_free(cc->password);
vk_free(cc->table);
dictRelease(cc->nodes);

if (cc->requests != NULL) {
listRelease(cc->requests);
}
listRelease(cc->requests);

memset(cc, 0xff, sizeof(*cc));
vk_free(cc);
Expand Down Expand Up @@ -2693,10 +2686,8 @@ void valkeyClusterReset(valkeyClusterContext *cc) {
} while (reply != NULL);
}

if (cc->requests) {
listRelease(cc->requests);
cc->requests = NULL;
}
listRelease(cc->requests);
cc->requests = NULL;

if (cc->need_update_route) {
status = valkeyClusterUpdateSlotmap(cc);
Expand Down

0 comments on commit d6586c7

Please sign in to comment.