Commit 1cc3490
cachedb_redis: fix NULL deref when redisConnect returns NULL
redisConnect() and redisConnectWithTimeout() can return NULL on allocation
failure. The existing check only handles ctx->err != REDIS_OK (non-NULL
ctx with error), so a NULL return falls through to redisSetTimeout(NULL, ...)
which dereferences the NULL pointer.
Add an explicit NULL check after the error-code check.
Also change the warned flag from char to int to avoid undefined behavior
on signed overflow after 127 connection-timeout warnings.1 parent 5623d3d commit 1cc3490
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
82 | 88 | | |
83 | 89 | | |
84 | 90 | | |
| |||
0 commit comments