summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-09 13:04:35 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-09 13:13:00 +0100
commitc4feaf10adac451b966be2647e8450817c14af2a (patch)
tree02835f33697451ab6d13a1175776a9f6b8e5e401
parentb2ab297defe8d174ec1bc1f272d8ddb7bc95a99f (diff)
eina_content: free memory in error paths
-rw-r--r--src/lib/eina/eina_abstract_content.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/lib/eina/eina_abstract_content.c b/src/lib/eina/eina_abstract_content.c
index bd74a518a4..2392681084 100644
--- a/src/lib/eina/eina_abstract_content.c
+++ b/src/lib/eina/eina_abstract_content.c
@@ -49,6 +49,8 @@ eina_content_converter_conversion_register(const char *from, const char *to, Ein
49 if (eina_content_converter_convert_can(from, to)) 49 if (eina_content_converter_convert_can(from, to))
50 { 50 {
51 ERR("Convertion from %s to %s is already possible", from, to); 51 ERR("Convertion from %s to %s is already possible", from, to);
52 eina_stringshare_del(shared_from);
53 free(node);
52 return EINA_FALSE; 54 return EINA_FALSE;
53 } 55 }
54 56
@@ -132,10 +134,17 @@ eina_content_new(Eina_Slice data, const char *type)
132 EINA_SAFETY_ON_NULL_RETURN_VAL(content, NULL); 134 EINA_SAFETY_ON_NULL_RETURN_VAL(content, NULL);
133 content->data = eina_slice_dup(data); 135 content->data = eina_slice_dup(data);
134 content->type = eina_stringshare_add(type); 136 content->type = eina_stringshare_add(type);
135 EINA_SAFETY_ON_NULL_RETURN_VAL(content->data.mem, NULL); 137 EINA_SAFETY_ON_NULL_GOTO(content->data.mem, err);
136 138
137 _eina_content_ref(content); 139 _eina_content_ref(content);
138 return content; 140 return content;
141err:
142 if (content)
143 {
144 free(content->data.mem);
145 content->data.mem = NULL;
146 }
147 return NULL;
139} 148}
140 149
141EAPI void 150EAPI void
@@ -416,7 +425,8 @@ eina_value_content_new(Eina_Content *content)
416{ 425{
417 Eina_Value *v = eina_value_new(EINA_VALUE_TYPE_CONTENT); 426 Eina_Value *v = eina_value_new(EINA_VALUE_TYPE_CONTENT);
418 427
419 eina_value_pset(v, &content); 428 if (!eina_value_pset(v, &content))
429 return NULL;
420 return v; 430 return v;
421} 431}
422 432
@@ -426,18 +436,21 @@ eina_value_content_init(Eina_Content *content)
426{ 436{
427 Eina_Value v; 437 Eina_Value v;
428 438
429 eina_value_setup(&v, EINA_VALUE_TYPE_CONTENT); 439 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_setup(&v, EINA_VALUE_TYPE_CONTENT), EINA_VALUE_EMPTY);
430 eina_value_pset(&v, &content); 440 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_pset(&v, &content), EINA_VALUE_EMPTY);
431 441
432 return v; 442 return v;
433} 443}
434 444
435
436Eina_Content* 445Eina_Content*
437eina_value_to_content(const Eina_Value *value) 446eina_value_to_content(const Eina_Value *value)
438{ 447{
439 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_get(value) == EINA_VALUE_TYPE_CONTENT, NULL); 448 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_get(value) == EINA_VALUE_TYPE_CONTENT, NULL);
440 Eina_Content *result = calloc(1, sizeof(Eina_Content)); 449 Eina_Content *result = calloc(1, sizeof(Eina_Content));
441 eina_value_pget(value, &result); 450 if (!eina_value_pget(value, &result))
451 {
452 free(result);
453 return NULL;
454 }
442 return result; 455 return result;
443} 456}