summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael-grunder <michael.grunder@gmail.com>2020-07-21 15:39:40 -0700
committermichael-grunder <michael.grunder@gmail.com>2020-07-21 15:39:40 -0700
commit3bb985314d0563857c84beef0097ffc8de2d9438 (patch)
tree94982a9beb98d99008f350ab45fc064f04c1b9be
parent18fc12c392f506c7be3cb0753304db6a3525a8a9 (diff)
Fix a static analysis false positive
Static analyzer's can't tell that hi_calloc is calloc-like, and report a potential null pointer dereference. This isn't possible but it's probably smarter to make the test anyway in the event code changes.
-rw-r--r--read.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/read.c b/read.c
index 544626e..0952469 100644
--- a/read.c
+++ b/read.c
@@ -641,13 +641,14 @@ void redisReaderFree(redisReader *r) {
if (r->reply != NULL && r->fn && r->fn->freeObject)
r->fn->freeObject(r->reply);
- /* We know r->task[i] is allocatd if i < r->tasks */
- for (int i = 0; i < r->tasks; i++) {
- hi_free(r->task[i]);
- }
+ if (r->task) {
+ /* We know r->task[i] is allocated if i < r->tasks */
+ for (int i = 0; i < r->tasks; i++) {
+ hi_free(r->task[i]);
+ }
- if (r->task)
hi_free(r->task);
+ }
sdsfree(r->buf);
hi_free(r);