From 7963177233ab51520dc4b512f68d04f34d1df07b Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Mon, 14 Jul 2014 10:43:21 -0700 Subject: [PATCH] Ticket #47859 - Coverity: 12692 & 12717 12717 - Resource leak - servers/plugins/uiduniq/uid.c Description: In uniqueness_entry_to_config, the return value of slapi_ch_calloc was checked if it was NULL or not. If NULL, the function returned without releasing values. This patch remove the NULL check and error return since the 2 arguments (i + 1, sizeof (Slapi_DN *)) never be 0 or negative, thus slapi_ch_calloc has no chance to return NULL. If allocation fails, it exits there. Note: introduced by commit c66b5e9f83a81d75d8137e86b5e7631507592099 (ticket #47823) --- ldap/servers/plugins/uiduniq/uid.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c index f4a9a8d..d1a1700 100644 --- a/ldap/servers/plugins/uiduniq/uid.c +++ b/ldap/servers/plugins/uiduniq/uid.c @@ -223,15 +223,9 @@ uniqueness_entry_to_config(Slapi_PBlock *pb, Slapi_Entry *config_entry) /* Subtrees where uniqueness is tested */ values = slapi_entry_attr_get_charray(config_entry, ATTR_UNIQUENESS_SUBTREES); if (values) { - - for (i = 0; values && values[i]; i++); - if ((tmp_config->subtrees = (Slapi_DN **) slapi_ch_calloc(i + 1, sizeof (Slapi_DN *))) == NULL) { - slapi_log_error(SLAPI_LOG_FATAL, plugin_name, "Config info: Fail to allocate subtree array \n"); - rc = SLAPI_PLUGIN_FAILURE; - goto done; - } - + /* slapi_ch_calloc never returns NULL unless the 2 args are 0 or negative. */ + tmp_config->subtrees = (Slapi_DN **) slapi_ch_calloc(i + 1, sizeof (Slapi_DN *))); /* copy the valid subtree DN into the config */ for (i = 0, nb_subtrees = 0; values && values[i]; i++) { if (slapi_dn_syntax_check(pb, values[i], 1)) { /* syntax check failed */ -- 1.8.1.4