Skip to content

Commit

Permalink
Do not segfault when closing last connection (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicencb authored Apr 6, 2022
1 parent 06ccb29 commit 874ce63
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ conn_close(conn_t *conn)
nextconn = queue_next_elem(&queue, conn);
/* dequeue connection */
queue_delete_elem(&queue, conn);
if (nextconn == conn) nextconn = NULL;
if (actconn == conn) actconn = nextconn;
return nextconn;
}
Expand Down
2 changes: 1 addition & 1 deletion src/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ queue_delete_elem(queue_t *queue, conn_t *conn)
conn_t *
queue_next_elem(queue_t *queue, conn_t *conn)
{
return (conn->next == NULL) ? queue->beg : conn->next;
return (conn == NULL || conn->next == NULL) ? queue->beg : conn->next;
}

0 comments on commit 874ce63

Please sign in to comment.