From d708686824f2ba70cf7c867752e9e52cb95f461b Mon Sep 17 00:00:00 2001 From: Vivek Dasmohapatra Date: Thu, 20 May 2010 15:43:15 +0100 Subject: Coverity 7707 REVERSE_INULL two gchar ** deref'd w/o check in set_param Also gchar ** strv_type_key potentially leaked in the 'clear' and 'unset' cases (cherry picked from commit c4b90bf71b14da5a6c11bd7ef1898cd2734ffbab) --- util/mc-tool.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/util/mc-tool.c b/util/mc-tool.c index 73a34497..315ef556 100644 --- a/util/mc-tool.c +++ b/util/mc-tool.c @@ -176,27 +176,34 @@ set_param (GHashTable *parameters, return FALSE; strv_type_key = g_strsplit (param_value, ":", 2); - if (strv_type_key[0] == NULL || - strv_type_key[1] == NULL || - strv_type_key[2] != NULL) - goto CLEANUP; + + if (strv_type_key == NULL || + strv_type_key[0] == NULL || + strv_type_key[1] == NULL || + strv_type_key[2] != NULL) + goto CLEANUP; + type = strv_type_key[0]; param = strv_type_key[1]; if (clear) { - if (strcmp (type, "clear") == 0 || strcmp (type, "unset") == 0) - { - g_ptr_array_add (clear, g_strdup (param)); - return TRUE; - } + if (strcmp (type, "clear") == 0 || strcmp (type, "unset") == 0) + { + g_ptr_array_add (clear, g_strdup (param)); + ret = TRUE; + goto CLEANUP; + } } strv_param_value = g_strsplit (param, "=", 2); - if (strv_param_value[0] == NULL || - strv_param_value[1] == NULL || - strv_param_value[2] != NULL) - goto CLEANUP; + + if (strv_param_value == NULL || + strv_param_value[0] == NULL || + strv_param_value[1] == NULL || + strv_param_value[2] != NULL) + goto CLEANUP; + key = strv_param_value[0]; value = strv_param_value[1]; @@ -234,9 +241,7 @@ set_param (GHashTable *parameters, g_free (gvalue); CLEANUP: - if (strv_param_value) g_strfreev (strv_param_value); - if (strv_type_key) g_strfreev (strv_type_key); return ret; } -- cgit v1.2.1