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.
This commit is contained in:
michael-grunder 2020-07-21 15:39:40 -07:00
parent 18fc12c392
commit 3bb985314d

5
read.c
View File

@ -641,13 +641,14 @@ void redisReaderFree(redisReader *r) {
if (r->reply != NULL && r->fn && r->fn->freeObject) if (r->reply != NULL && r->fn && r->fn->freeObject)
r->fn->freeObject(r->reply); r->fn->freeObject(r->reply);
/* We know r->task[i] is allocatd if i < r->tasks */ if (r->task) {
/* We know r->task[i] is allocated if i < r->tasks */
for (int i = 0; i < r->tasks; i++) { for (int i = 0; i < r->tasks; i++) {
hi_free(r->task[i]); hi_free(r->task[i]);
} }
if (r->task)
hi_free(r->task); hi_free(r->task);
}
sdsfree(r->buf); sdsfree(r->buf);
hi_free(r); hi_free(r);