Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect assertion in client list operations #1800

Open
wants to merge 5 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/adlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#include <stdlib.h>
#include "adlist.h"

#include "serverassert.h"
#include "zmalloc.h"

/* Create a new list. The created list can be freed with
Expand Down Expand Up @@ -187,14 +189,23 @@ void listDelNode(list *list, listNode *node) {
* Remove the specified node from the list without freeing it.
*/
void listUnlinkNode(list *list, listNode *node) {
if (node->prev)
assert(list->len > 0);

if (node->prev) {
assert(node->prev->next == node);
node->prev->next = node->next;
else
} else {
assert(list->head == node);
list->head = node->next;
if (node->next)
}

if (node->next) {
assert(node->next->prev == node);
node->next->prev = node->prev;
else
} else {
assert(list->tail == node);
list->tail = node->prev;
}

node->next = NULL;
node->prev = NULL;
Expand Down
1 change: 0 additions & 1 deletion src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,6 @@ void unlinkClient(client *c) {

/* Remove from the list of pending writes if needed. */
if (c->flag.pending_write) {
serverAssert(&c->clients_pending_write_node.next != NULL || &c->clients_pending_write_node.prev != NULL);
if (c->io_write_state == CLIENT_IDLE) {
listUnlinkNode(server.clients_pending_write, &c->clients_pending_write_node);
} else {
Expand Down
Loading