summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd/back-ldbm
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2010-07-24 01:34:02 -0500
committerNoriko Hosoi <nhosoi@redhat.com>2010-08-19 16:59:50 -0700
commit3ac3cfc84bdbbc695a251ad057a435b7571fec46 (patch)
tree9cb05787b59774beea02abfea24218eddf6b1d97 /ldap/servers/slapd/back-ldbm
parentc4962651906ef23ad353ad00eddadd44d002158d (diff)
downloadds-3ac3cfc84bdbbc695a251ad057a435b7571fec46.tar.gz
ds-3ac3cfc84bdbbc695a251ad057a435b7571fec46.tar.xz
ds-3ac3cfc84bdbbc695a251ad057a435b7571fec46.zip
Bug 617630 - fix coverify Defect Type: Resource leaks issues CID 12052 - 12093
https://bugzilla.redhat.com/show_bug.cgi?id=617630 Resolves: bug 617630 Bug description: fix coverify Defect Type: Resource leaks issues CID 12071. description: perfctrs_init() has been modified to release unused resources when error occurs.
Diffstat (limited to 'ldap/servers/slapd/back-ldbm')
-rw-r--r--ldap/servers/slapd/back-ldbm/perfctrs.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/ldap/servers/slapd/back-ldbm/perfctrs.c b/ldap/servers/slapd/back-ldbm/perfctrs.c
index 5b7c68f0..521ba1f2 100644
--- a/ldap/servers/slapd/back-ldbm/perfctrs.c
+++ b/ldap/servers/slapd/back-ldbm/perfctrs.c
@@ -92,9 +92,7 @@ char * string_concatenate(char *a, char* b)
string_length = strlen(a) + strlen(b) + 1;
string = slapi_ch_malloc(string_length);
- if (NULL == string) {
- return string;
- }
+
sprintf(string,"%s%s",a,b);
return string;
}
@@ -176,12 +174,12 @@ void perfctrs_init(struct ldbminfo *li, perfctrs_private **ret_priv)
* On Windows, the performance counters reside in shared memory.
*/
if (NULL == instance_name) {
- return;
+ goto error;
}
/* Invent the name for the shared memory region */
string = string_concatenate(instance_name,PERFCTRS_REGION_SUFFIX);
if (NULL == string) {
- return;
+ goto error;
}
#endif
@@ -189,9 +187,6 @@ void perfctrs_init(struct ldbminfo *li, perfctrs_private **ret_priv)
* We need the perfctrs_private area on all platforms.
*/
priv = (perfctrs_private *)slapi_ch_calloc(1,sizeof(perfctrs_private));
- if (NULL == priv) {
- return;
- }
#if defined(_WIN32)
/* Try to open the shared memory region */
@@ -200,7 +195,7 @@ void perfctrs_init(struct ldbminfo *li, perfctrs_private **ret_priv)
/* Invent the name for the update mutex */
string = string_concatenate(instance_name,PERFCTRS_MUTEX_SUFFIX);
if (NULL == string) {
- return;
+ goto error;
}
open_event(string,priv);
free(string);
@@ -210,12 +205,17 @@ void perfctrs_init(struct ldbminfo *li, perfctrs_private **ret_priv)
/*
* On other platforms, the performance counters reside in regular memory.
*/
- if ( NULL == ( priv->memory = slapi_ch_calloc( 1, sizeof( performance_counters )))) {
- return;
- }
+ priv->memory = slapi_ch_calloc( 1, sizeof( performance_counters ));
#endif
*ret_priv = priv;
+ return;
+
+error:
+#if !defined(_WIN32)
+ if (priv) slapi_ch_free((void**)&priv->memory);
+#endif
+ slapi_ch_free((void**)&priv);
}
/* Terminate perf ctrs */