Skip to content

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