From 7ff27c1699efe0e16625459814b4ead562f5f4f7 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 12:51:41 -0600 Subject: [PATCH 1/2] variant: return NULL on allocation exception (CID 507937) Signed-off-by: Eduardo Silva --- src/cfl_variant.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cfl_variant.c b/src/cfl_variant.c index 1b688b8..cc2a8a7 100644 --- a/src/cfl_variant.c +++ b/src/cfl_variant.c @@ -136,7 +136,7 @@ struct cfl_variant *cfl_variant_create_from_bytes(char *value, size_t length, in instance->data.as_bytes = cfl_sds_create_len(value, length); if (instance->data.as_bytes == NULL) { free(instance); - instance = NULL; + return NULL; } } cfl_variant_size_set(instance, length); From 8ec437a330eda8fab5a8d6a95ac4d732bdca5c62 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 12:53:09 -0600 Subject: [PATCH 2/2] variant: return NULL on allocation exception (CID 507556) Signed-off-by: Eduardo Silva --- src/cfl_variant.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cfl_variant.c b/src/cfl_variant.c index cc2a8a7..3e7065e 100644 --- a/src/cfl_variant.c +++ b/src/cfl_variant.c @@ -104,7 +104,7 @@ struct cfl_variant *cfl_variant_create_from_string_s(char *value, size_t value_s instance->data.as_string = cfl_sds_create_len(value, value_size); if (instance->data.as_string == NULL) { free(instance); - instance = NULL; + return NULL; } }