summaryrefslogtreecommitdiff
path: root/src/adlist.c
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2021-05-03 18:39:07 +0800
committerGitHub <noreply@github.com>2021-05-03 13:39:07 +0300
commitccb76e5688a7a5655c8ed2c8313f6ad7d54e4d2d (patch)
treef813e1c08fd78bbd5894f8784fd99a145c3a4963 /src/adlist.c
parent5100ef9f8246dec6590f35f6b9f0b88c2dea0cfb (diff)
downloadredis-ccb76e5688a7a5655c8ed2c8313f6ad7d54e4d2d.tar.gz
Free value if dup succeed but listAddNodeTail failed. (#8901)
This fix is in dead code. see redisOutOfMemoryHandler an allocation can't fail. but maybe someone will copy this code to a different project some day, better have this fixed Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/adlist.c')
-rw-r--r--src/adlist.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/adlist.c b/src/adlist.c
index 7670b2c10..2e811e02e 100644
--- a/src/adlist.c
+++ b/src/adlist.c
@@ -269,9 +269,14 @@ list *listDup(list *orig)
listRelease(copy);
return NULL;
}
- } else
+ } else {
value = node->value;
+ }
+
if (listAddNodeTail(copy, value) == NULL) {
+ /* Free value if dup succeed but listAddNodeTail failed. */
+ if (copy->free) copy->free(value);
+
listRelease(copy);
return NULL;
}