From ec5a296da501600ec35c3a9d6284b3d3c3e4346a Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Thu, 29 Jul 2010 01:34:14 -0500 Subject: Bug 619122 - fix coverify Defect Type: Resource leaks issues CID 11975 - 12053 https://bugzilla.redhat.com/show_bug.cgi?id=619122 Resolves: bug 619122 Bug description: fix coverify Defect Type: Resource leaks issues CID 11994. description: The acl__malloc_aclpb() has been modified to release resources when an error occurs. --- ldap/servers/plugins/acl/acl_ext.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'ldap') diff --git a/ldap/servers/plugins/acl/acl_ext.c b/ldap/servers/plugins/acl/acl_ext.c index fbe469fa..61d8dd11 100644 --- a/ldap/servers/plugins/acl/acl_ext.c +++ b/ldap/servers/plugins/acl/acl_ext.c @@ -567,33 +567,33 @@ acl__malloc_aclpb ( ) if ((aclpb->aclpb_proplist = PListNew(NULL)) == NULL) { slapi_log_error (SLAPI_LOG_FATAL, plugin_name, "Unable to allocate the aclprop PList\n"); - return NULL; + goto error; } if (PListInitProp(aclpb->aclpb_proplist, 0, DS_PROP_ACLPB, aclpb, 0) < 0) { slapi_log_error(SLAPI_LOG_FATAL, plugin_name, "Unable to set the ACL PBLOCK in the Plist\n"); - return NULL; + goto error; } if (PListInitProp(aclpb->aclpb_proplist, 0, DS_ATTR_USERDN, aclpb, 0) < 0) { slapi_log_error(SLAPI_LOG_FATAL, plugin_name, "Unable to set the USER DN in the Plist\n"); - return NULL; + goto error; } if (PListInitProp(aclpb->aclpb_proplist, 0, DS_ATTR_AUTHTYPE, aclpb, 0) < 0) { slapi_log_error(SLAPI_LOG_FATAL, plugin_name, "Unable to set the AUTH TYPE in the Plist\n"); - return NULL; + goto error; } if (PListInitProp(aclpb->aclpb_proplist, 0, DS_ATTR_ENTRY, aclpb, 0) < 0) { slapi_log_error(SLAPI_LOG_FATAL, plugin_name, "Unable to set the ENTRY TYPE in the Plist\n"); - return NULL; + goto error; } if (PListInitProp(aclpb->aclpb_proplist, 0, DS_ATTR_SSF, aclpb, 0) < 0) { slapi_log_error(SLAPI_LOG_FATAL, plugin_name, "Unable to set the SSF in the Plist\n"); - return NULL; + goto error; } /* @@ -608,7 +608,7 @@ acl__malloc_aclpb ( ) if (aclpb->aclpb_acleval == NULL) { slapi_log_error(SLAPI_LOG_FATAL, plugin_name, "Unable to allocate the acleval block\n"); - return NULL; + goto error; } /* * This is a libaccess routine. @@ -648,6 +648,12 @@ acl__malloc_aclpb ( ) return aclpb; +error: + if (aclpb->aclpb_acleval) ACL_EvalDestroy(NULL, NULL, aclpb->aclpb_acleval); + if (aclpb->aclpb_proplist) PListDestroy(aclpb->aclpb_proplist); + slapi_ch_free((void**)&aclpb); + + return NULL; } /* Initializes the aclpb */ -- cgit