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

Prevent is_circular function from infinite loop #179

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Changes from 1 commit
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
10 changes: 8 additions & 2 deletions qtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,17 +880,23 @@ static bool do_merge(int argc, char *argv[])
static bool is_circular()
{
struct list_head *cur = current->q->next;
struct list_head *fast = (cur) ? cur->next : NULL;
while (cur != current->q) {
if (!cur)
if (!cur || !fast || !(fast->next))
return false;
if (cur == fast)
return false;
cur = cur->next;
fast = fast->next->next;
}

cur = current->q->prev;
fast = (cur) ? cur->prev : NULL;
wilson20010327 marked this conversation as resolved.
Show resolved Hide resolved
while (cur != current->q) {
if (!cur)
if (!cur || !fast || !(fast->prev))
return false;
cur = cur->prev;
fast = fast->prev->prev;
}
return true;
}
Expand Down
Loading