From b4fb0eae14911413612273c152cb935a6f8804b2 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Fri, 30 Jul 2010 01:25:39 -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 12015. description: The _cl5ReadRUV() has been modified to release vals before it returns. --- ldap/servers/plugins/replication/cl5_api.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c index 8b79887c..ece4d273 100644 --- a/ldap/servers/plugins/replication/cl5_api.c +++ b/ldap/servers/plugins/replication/cl5_api.c @@ -4481,7 +4481,7 @@ static int _cl5ReadRUV (const char *replGen, Object *obj, PRBool purge) int rc; char csnStr [CSN_STRSIZE]; DBT key={0}, data={0}; - struct berval **vals; + struct berval **vals = NULL; CL5DBFile *file; char *pos; char *agmt_name; @@ -4510,7 +4510,7 @@ static int _cl5ReadRUV (const char *replGen, Object *obj, PRBool purge) rc = _cl5ReadBervals (&vals, &pos, data.size); slapi_ch_free (&(data.data)); if (rc != CL5_SUCCESS) - return rc; + goto done; if (purge) rc = ruv_init_from_bervals(vals, &file->purgeRUV); @@ -4523,26 +4523,31 @@ static int _cl5ReadRUV (const char *replGen, Object *obj, PRBool purge) "%s: _cl5ReadRUV: failed to initialize %s ruv; " "RUV error %d\n", agmt_name, purge? "purge" : "upper bound", rc); - return CL5_RUV_ERROR; + rc = CL5_RUV_ERROR; + goto done; } - ber_bvecfree(vals); - /* delete the entry; it is re-added when file is successfully closed */ file->db->del (file->db, NULL, &key, DEFAULT_DB_OP_FLAGS); - return CL5_SUCCESS; + rc = CL5_SUCCESS; + goto done; case DB_NOTFOUND: /* RUV is lost - need to construct */ rc = _cl5ConstructRUV (replGen, obj, purge); - return rc; + goto done; default: slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, "%s: _cl5ReadRUV: failed to get purge RUV; " "db error - %d %s\n", agmt_name, rc, db_strerror(rc)); - return CL5_DB_ERROR; + rc = CL5_DB_ERROR; + goto done; } + +done: + ber_bvecfree(vals); + return rc; } static int _cl5WriteRUV (CL5DBFile *file, PRBool purge) -- cgit