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

Fixed crash when #1223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions adapters/libuv.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ static void redisLibuvSetTimeout(void *privdata, struct timeval tv) {
static void redisLibuvCleanup(void *privdata) {
redisLibuvEvents* p = (redisLibuvEvents*)privdata;

if (p == NULL)
Copy link
Contributor

@AgranatMarkit AgranatMarkit Nov 14, 2023

Choose a reason for hiding this comment

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

  1. It's not a good practice, to add such checks, because they could affect performance.
  2. You couldn't check redundant cleanups in client code, if it's needed.
  3. It's better to make early return before casting on line 131.

Copy link
Author

Choose a reason for hiding this comment

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

Hi Mark

  1. This is a best practice to check variables
  2. This is internal function calls from driver
  3. May be

P.s. Марк, ты вообще офигел :)
Я сейчас вспомню Серафим и всякое разное :)

Copy link
Contributor

Choose a reason for hiding this comment

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

As i see, it's better to add check for nullability here, because there are exist another adapters, and their cleanup functions will be also called with NULL privdata.

return;

p->context = NULL; // indicate that context might no longer exist
if (p->timer.data) {
uv_close((uv_handle_t*)&p->timer, on_timer_close);
Expand Down