Browse Source

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)

https://fedorahosted.org/389/ticket/47859

Reviewed by [email protected] (Thank you, Rich!!)
Noriko Hosoi 11 years ago
parent
commit
03f85ec06f
1 changed files with 2 additions and 8 deletions
  1. 2 8
      ldap/servers/plugins/uiduniq/uid.c

+ 2 - 8
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 */