Skip to content
Open
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
10 changes: 6 additions & 4 deletions lib/PgSQL_Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1270,13 +1270,15 @@ void add_task(
}

void rm_task_fast(task_poll_t& task_poll, size_t idx) {
if (idx > task_poll.size || idx < 0) {
proxy_error("Receveid invalid task index idx=%lu", idx);
if (idx >= task_poll.size) {
Comment thread
Snehil-Shah marked this conversation as resolved.
proxy_error("Received invalid task index idx=%zu\n", idx);
Comment on lines +1273 to +1274

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by correctness fix. idx is unsigned so the second check was a no-op, and idx == task_poll.size is also an invalid task index.

assert(0);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

task_poll.fds[idx] = task_poll.fds[task_poll.size - 1];
task_poll.tasks[idx] = std::move(task_poll.tasks[task_poll.size - 1]);
if (idx != task_poll.size - 1) {
task_poll.fds[idx] = task_poll.fds[task_poll.size - 1];
task_poll.tasks[idx] = std::move(task_poll.tasks[task_poll.size - 1]);
}
task_poll.size--;
}

Expand Down