summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2010-08-19 13:45:03 -0700
committerNoriko Hosoi <nhosoi@redhat.com>2010-08-19 14:27:07 -0700
commit92ee0f56c4bdbef67c88b39f0203c36982191fb7 (patch)
tree89a16a75d6fb85963d5af3ac5e7d1469f8e61d61
parenta98a49328cf470d3b13cebebfc1229a843549121 (diff)
downloadds-92ee0f56c4bdbef67c88b39f0203c36982191fb7.tar.gz
ds-92ee0f56c4bdbef67c88b39f0203c36982191fb7.tar.xz
ds-92ee0f56c4bdbef67c88b39f0203c36982191fb7.zip
Bug 619122 - fix coverity Defect Type: Resource leaks issues CID 11975 - 12051
https://bugzilla.redhat.com/show_bug.cgi?id=619122 Resolves: bug 619122 Bug description: fix coverify Defect Type: Resource leaks issues CID 12025. description: The ruvInit() has been modified to release resources if an error occurs.
-rw-r--r--ldap/servers/plugins/replication/repl5_ruv.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c
index 9dd512a7..9f0d99a5 100644
--- a/ldap/servers/plugins/replication/repl5_ruv.c
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
@@ -1441,21 +1441,9 @@ ruvInit (RUV **ruv, int initCount)
/* allocate new RUV */
*ruv = (RUV *)slapi_ch_calloc (1, sizeof (RUV));
- if (ruv == NULL)
- {
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "ruvInit: memory allocation failed\n");
- return RUV_MEMORY_ERROR;
- }
/* allocate elements */
- (*ruv)->elements = dl_new ();
- if ((*ruv)->elements == NULL)
- {
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "ruvInit: memory allocation failed\n");
- return RUV_MEMORY_ERROR;
- }
+ (*ruv)->elements = dl_new (); /* never returns NULL */
dl_init ((*ruv)->elements, initCount);
@@ -1465,6 +1453,10 @@ ruvInit (RUV **ruv, int initCount)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
"ruvInit: failed to create lock\n");
+ if (*ruv) {
+ dl_free(&(*ruv)->elements);
+ }
+ slapi_ch_free((void**)ruv);
return RUV_NSPR_ERROR;
}