This defect was found by the coccinelle script "unchecked-strdup.cocci".
It can be backported to all supported branches.
---
 src/compression.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/compression.c b/src/compression.c
index a4464e09b..edf5553c1 100644
--- a/src/compression.c
+++ b/src/compression.c
@@ -119,6 +119,8 @@ int comp_append_type(struct comp_type **types, const char 
*type)
                return 1;
        comp_type->name_len = strlen(type);
        comp_type->name = strdup(type);
+       if (!comp_type->name)
+               return 1;
        comp_type->next = *types;
        *types = comp_type;
        return 0;
-- 
2.46.0.windows.1



Reply via email to