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

Fixed crash when #1223

wants to merge 1 commit into from

Conversation

kaegoorn
Copy link

@kaegoorn kaegoorn commented Sep 1, 2023

Fixed crash when __redisAsyncFree is called if redisLibuvAttach has not completed

` context = redisAsyncConnect(host, port);

    if (redisLibuvAttach(context, loop) != REDIS_OK)
         redisAsyncFree(context); // <--- crash

`

Fixed crash when __redisAsyncFree is called if redisLibuvAttach has not completed
@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants