Browse Source

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.
Endi S. Dewata 15 years ago
parent
commit
ec5a296da5
1 changed files with 13 additions and 7 deletions
  1. 13 7
      ldap/servers/plugins/acl/acl_ext.c

+ 13 - 7
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 */