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>
This commit is contained in:
Binbin 2021-05-03 18:39:07 +08:00 committed by GitHub
parent 5100ef9f82
commit ccb76e5688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -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;
}