From 85f1d386d8f3e7d59f010ae17bb8ecc03d9d2b47 Mon Sep 17 00:00:00 2001 From: rbdpngn Date: Wed, 20 Jul 2005 14:21:40 +0000 Subject: [PATCH] Fix a memory leak if the local bundle is NULL. Use a generic FAIL error when the local bundle is NULL. Return a more detailed error report from the type add function. SVN revision: 15839 --- .../ecore/src/lib/ecore_config/ecore_config.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/legacy/ecore/src/lib/ecore_config/ecore_config.c b/legacy/ecore/src/lib/ecore_config/ecore_config.c index 33b4bc73a3..df6ea43449 100644 --- a/legacy/ecore/src/lib/ecore_config/ecore_config.c +++ b/legacy/ecore/src/lib/ecore_config/ecore_config.c @@ -549,6 +549,7 @@ ecore_config_typed_val(Ecore_Config_Prop * e, const void *val, int type) static int ecore_config_typed_add(const char *key, const void *val, int type) { + int error = ECORE_CONFIG_ERR_SUCC; Ecore_Config_Prop *e; Ecore_Config_Bundle *t; @@ -561,23 +562,29 @@ ecore_config_typed_add(const char *key, const void *val, int type) memset(e, 0, sizeof(Ecore_Config_Prop)); if (!(e->key = strdup(key))) - goto ret_free_nte; + { + error = ECORE_CONFIG_ERR_OOM; + goto ret_free_nte; + } - if (ecore_config_typed_val(e, val, type) == ECORE_CONFIG_ERR_OOM) + if ((error = ecore_config_typed_val(e, val, type) != ECORE_CONFIG_ERR_SUCC)) goto ret_free_key; e->next = t ? t->data : NULL; if (t) - t->data = e; - - return ECORE_CONFIG_ERR_SUCC; + { + t->data = e; + return ECORE_CONFIG_ERR_SUCC; + } ret_free_key: free(e->key); ret_free_nte: free(e); ret: - return ECORE_CONFIG_ERR_OOM; + if (error == ECORE_CONFIG_ERR_SUCC) + error = ECORE_CONFIG_ERR_FAIL; + return error; } static int