ldap/servers/plugins/chainingdb/cb_instance.c | 8 +++++--
ldap/servers/plugins/dna/dna.c | 6 +++++
ldap/servers/plugins/memberof/memberof_config.c | 1
ldap/servers/plugins/replication/cl5_config.c | 7 ++++--
ldap/servers/slapd/back-ldbm/cache.c | 3 ++
ldap/servers/slapd/back-ldbm/dblayer.c | 4 +--
ldap/servers/slapd/back-ldbm/instance.c | 5 ++--
ldap/servers/slapd/bind.c | 1
ldap/servers/slapd/conntable.c | 3 +-
ldap/servers/slapd/entry.c | 22 +++++++------------
ldap/servers/slapd/log.c | 27 ++++++++++++------------
ldap/servers/slapd/operation.c | 1
ldap/servers/slapd/plugin.c | 1
ldap/servers/slapd/snmp_collator.c | 14 +++++++++++-
ldap/servers/slapd/task.c | 2 +
ldap/servers/slapd/valueset.c | 7 +++++-
16 files changed, 74 insertions(+), 38 deletions(-)
New commits:
commit 2b263e8fa38a44dd1e03cd68c04b6d04ef9b5380
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 15:18:58 2011 -0700
Bug 697027 - 16 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 16]
Description: Adding slapi_ch_free_string to free pb_instance_name
allocated in the restore task.
diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c
index 9b2e5ed..999d004 100644
--- a/ldap/servers/slapd/task.c
+++ b/ldap/servers/slapd/task.c
@@ -1434,6 +1434,7 @@ static void task_restore_thread(void *arg)
slapi_task_finish(task, rv);
slapi_ch_free((void **)&pb->pb_seq_val);
+ slapi_ch_free_string(&pb->pb_instance_name);
slapi_pblock_destroy(pb);
g_decr_active_threadcnt();
}
@@ -1535,6 +1536,7 @@ static int task_restore_add(Slapi_PBlock *pb, Slapi_Entry *e,
*returncode = LDAP_OPERATIONS_ERROR;
rv = SLAPI_DSE_CALLBACK_ERROR;
slapi_ch_free((void **)&mypb->pb_seq_val);
+ slapi_ch_free_string(&pb->pb_instance_name);
slapi_pblock_destroy(mypb);
goto out;
}
commit 9ef77fa5dc8575f62fd1c9d851f0b7607fb8ac81
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 15:02:08 2011 -0700
Bug 697027 - 15 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 15]
Description: 1) Adding slapi_rdn_done to release work Slapi_RDN
mysrdn filled in _entry_set_tombstone_rdn.
2) Getting rid of unnecessary slapi_rdn_done, which is taken
care in slapi_rdn_replace_rdn.
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 7a015ff..24f18aa 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -3877,21 +3877,20 @@ _entry_set_tombstone_rdn(Slapi_Entry *e, char *normdn)
Slapi_RDN mysrdn = {0};
rc = slapi_rdn_init_all_dn(&mysrdn, sepp + 1);
if (rc) {
- slapi_log_error(SLAPI_LOG_FATAL, "str2entry",
+ slapi_log_error(SLAPI_LOG_FATAL, "_entry_set_tombstone_rdn",
"Failed to convert DN %s to RDN\n", sepp + 1);
+ slapi_rdn_done(&mysrdn);
goto bail;
}
sepp = PL_strchr(sepp + 1, ',');
if (sepp) {
- Slapi_RDN *srdn = slapi_entry_get_srdn(e);
/* nsuniqueid=042d8081-...-ca8fe9f7,uid=tuser, */
/* ^ */
*sepp = '\0';
slapi_rdn_replace_rdn(&mysrdn, tombstone_rdn);
- slapi_rdn_done(srdn);
slapi_entry_set_srdn(e, &mysrdn);
- slapi_rdn_done(&mysrdn);
}
+ slapi_rdn_done(&mysrdn);
}
}
bail:
commit 03476f2d843ba2bed7f07f54acf475fdc2507cfb
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 14:48:34 2011 -0700
Bug 697027 - 14 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 14]
Description: 1) Fixing file descriptor leaks in the non-apply cases
(log_update_error/auditlogdir).
2) Cleaning up log_error/access/audit_file as well as log_error/
access/auditinfo_file before assigning a new file name. Plus,
changing to use slapi_ch_smprintf instead of strdup a static buffer
(error/access/audit_log_openf).
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index f5ad2dc..1c048a4 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -292,6 +292,7 @@ void g_log_init(int log_enabled)
loginfo.log_access_ctime = 0L;
loginfo.log_access_fdes = NULL;
loginfo.log_access_file = NULL;
+ loginfo.log_accessinfo_file = NULL;
loginfo.log_numof_access_logs = 1;
loginfo.log_access_logchain = NULL;
loginfo.log_access_buffer = log_create_buffer(LOG_BUFFER_MAXSIZE);
@@ -320,6 +321,7 @@ void g_log_init(int log_enabled)
loginfo.log_error_exptime_secs = -1; /* default: -1 */
loginfo.log_error_ctime = 0L;
loginfo.log_error_file = NULL;
+ loginfo.log_errorinfo_file = NULL;
loginfo.log_error_fdes = NULL;
loginfo.log_numof_error_logs = 1;
loginfo.log_error_logchain = NULL;
@@ -346,6 +348,7 @@ void g_log_init(int log_enabled)
loginfo.log_audit_exptime_secs = -1; /* default: -1 */
loginfo.log_audit_ctime = 0L;
loginfo.log_audit_file = NULL;
+ loginfo.log_auditinfo_file = NULL;
loginfo.log_numof_audit_logs = 1;
loginfo.log_audit_fdes = NULL;
loginfo.log_audit_logchain = NULL;
@@ -544,12 +547,12 @@ log_update_errorlogdir(char *pathname, int apply)
log__error_emergency(buffer, 0, 0);
return LDAP_UNWILLING_TO_PERFORM;
}
+ LOG_CLOSE(fp);
/* skip the rest if we aren't doing this for real */
if ( !apply ) {
return LDAP_SUCCESS;
}
- LOG_CLOSE(fp);
/*
** The user has changed the error log directory. That means we
@@ -618,12 +621,12 @@ log_update_auditlogdir(char *pathname, int apply)
/* stay with the current log file */
return LDAP_UNWILLING_TO_PERFORM;
}
+ LOG_CLOSE(fp);
/* skip the rest if we aren't doing this for real */
if ( !apply ) {
return LDAP_SUCCESS;
}
- LOG_CLOSE(fp);
/*
** The user has changed the audit log directory. That means we
@@ -1673,17 +1676,15 @@ int error_log_openf( char *pathname, int locked)
int rv = 0;
int logfile_type =0;
- char buf[BUFSIZ];
if (!locked) LOG_ERROR_LOCK_WRITE ();
/* save the file name */
- slapi_ch_free ((void**)&loginfo.log_error_file);
+ slapi_ch_free_string(&loginfo.log_error_file);
loginfo.log_error_file = slapi_ch_strdup(pathname);
/* store the rotation info fiel path name */
- PR_snprintf (buf, sizeof(buf), "%s.rotationinfo",pathname);
- slapi_ch_free ((void**)&loginfo.log_errorinfo_file);
- loginfo.log_errorinfo_file = slapi_ch_strdup ( buf );
+ slapi_ch_free_string(&loginfo.log_errorinfo_file);
+ loginfo.log_errorinfo_file = slapi_ch_smprintf("%s.rotationinfo", pathname);
/*
** Check if we have a log file already. If we have it then
@@ -1712,16 +1713,16 @@ audit_log_openf( char *pathname, int locked)
int rv=0;
int logfile_type = 0;
- char buf[BUFSIZ];
if (!locked) LOG_AUDIT_LOCK_WRITE( );
/* store the path name */
+ slapi_ch_free_string(&loginfo.log_audit_file);
loginfo.log_audit_file = slapi_ch_strdup ( pathname );
/* store the rotation info file path name */
- PR_snprintf (buf, sizeof(buf), "%s.rotationinfo",pathname);
- loginfo.log_auditinfo_file = slapi_ch_strdup ( buf );
+ slapi_ch_free_string(&loginfo.log_auditinfo_file);
+ loginfo.log_auditinfo_file = slapi_ch_smprintf("%s.rotationinfo", pathname);
/*
** Check if we have a log file already. If we have it then
@@ -2089,16 +2090,16 @@ int access_log_openf(char *pathname, int locked)
{
int rv=0;
int logfile_type = 0;
- char buf[BUFSIZ];
if (!locked) LOG_ACCESS_LOCK_WRITE( );
/* store the path name */
+ slapi_ch_free_string(&loginfo.log_access_file);
loginfo.log_access_file = slapi_ch_strdup ( pathname );
/* store the rotation info fiel path name */
- PR_snprintf (buf, sizeof(buf), "%s.rotationinfo",pathname);
- loginfo.log_accessinfo_file = slapi_ch_strdup ( buf );
+ slapi_ch_free_string(&loginfo.log_accessinfo_file);
+ loginfo.log_accessinfo_file = slapi_ch_smprintf("%s.rotationinfo", pathname);
/*
** Check if we have a log file already. If we have it then
commit f038ee78a1ef021d2790cebc26020bdf237859f6
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 14:30:53 2011 -0700
Bug 697027 - 13 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 13]
Description: When the log level is set to LDAP_DEBUG_CONNS,
connection_table_dump_activity_to_errors_log could have
accessed the negative-th element of array ct->fd.
diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c
index 29c6f8e..df4f2f8 100644
--- a/ldap/servers/slapd/conntable.c
+++ b/ldap/servers/slapd/conntable.c
@@ -484,7 +484,8 @@ connection_table_dump_activity_to_errors_log(Connection_Table *ct)
/* Find the connection we are referring to */
int j= c->c_fdi;
PR_Lock( c->c_mutex );
- if ( c->c_sd != SLAPD_INVALID_SOCKET && c->c_prfd == ct->fd[j].fd )
+ if ( (c->c_sd != SLAPD_INVALID_SOCKET) &&
+ (j >= 0) && (c->c_prfd == ct->fd[j].fd) )
{
int r = ct->fd[j].out_flags & SLAPD_POLL_FLAGS;
if ( r )
commit e227048e66a3215431a6dc9902b540b342f99d44
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 14:18:55 2011 -0700
Bug 697027 - 12 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 12]
Description: The caller of valuearray_remove_value is responsible
for freeing the removed value. Adding slapi_value_free to free it.
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index a2ae334..6a3a205 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -399,6 +399,7 @@ valuearray_remove_value_atindex(Slapi_Value **va, int index)
* Find the value in the array,
* shunt up the array to cover it,
* return a ptr to the value.
+ * The caller is responsible for freeing the value.
*/
Slapi_Value *
valuearray_remove_value(const Slapi_Attr *a, Slapi_Value **va, const Slapi_Value *v)
@@ -1043,9 +1044,13 @@ void
valueset_remove_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s)
{
Slapi_Value v;
+ Slapi_Value *removed;
value_init(&v,NULL,CSN_TYPE_NONE,NULL);
slapi_value_set_string(&v,s);
- valuearray_remove_value(a,vs->va,&v);
+ removed = valuearray_remove_value(a, vs->va, &v);
+ if(removed) {
+ slapi_value_free(&removed);
+ }
value_done(&v);
}
commit 3b33f12165d37bae1e19aae62955e88e717c259a
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 14:09:09 2011 -0700
Bug 697027 - 11 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 11]
Description: Fixing a copy & paste mistake: pathname1 -> pathname2.
Adding PR_CloseDir to release dirhandle.
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c
b/ldap/servers/slapd/back-ldbm/dblayer.c
index 363c62d..ca2a2df 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -5403,7 +5403,7 @@ dblayer_backup(struct ldbminfo *li, char *dest_dir, Slapi_Task
*task)
return_value = dblayer_copyfile(pathname1, pathname2,
0, priv->dblayer_file_mode);
slapi_ch_free_string(&pathname1);
- slapi_ch_free_string(&pathname1);
+ slapi_ch_free_string(&pathname2);
slapi_ch_free_string(&changelog_destdir);
}
if (priv->dblayer_enable_transactions) {
@@ -5700,8 +5700,8 @@ static int dblayer_copy_dirand_contents(char* src_dir, char*
dst_dir, int mode,
}
if (0 > return_value)
break;
-
}
+ PR_CloseDir(dirhandle);
}
return return_value;
}
commit 76f8f49065cd2a4c27ffd340fda0b0c525b43766
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 13:59:12 2011 -0700
Bug 697027 - 10 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 10]
Description: Changing to create a configuration lock only when
it is not created yet.
diff --git a/ldap/servers/plugins/replication/cl5_config.c
b/ldap/servers/plugins/replication/cl5_config.c
index 0698c55..1d0dfe3 100644
--- a/ldap/servers/plugins/replication/cl5_config.c
+++ b/ldap/servers/plugins/replication/cl5_config.c
@@ -77,8 +77,11 @@ int changelog5_config_init()
{
/* The FE DSE *must* be initialised before we get here */
- /* create the configuration lock */
- s_configLock = PR_NewRWLock(PR_RWLOCK_RANK_NONE, "config_lock");
+ /* create the configuration lock, if not yet created. */
+ if (!s_configLock)
+ {
+ s_configLock = PR_NewRWLock(PR_RWLOCK_RANK_NONE, "config_lock");
+ }
if (s_configLock == NULL)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
commit be34548e9d9f61ef98086a1ab67ad15f63eb0c05
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 13:42:42 2011 -0700
Bug 697027 - 9 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 9]
Description: 1) Adding more checks to snmp_collator_stop and
snmp_collator_sem_wait before proceeding the operation.
2) Fixing a return value for an error case in plugin_enabled
-- in case a plugin entry did not exist, plugin_enabled used
to return "enabled".
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index d60d191..cc88dc4 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -2990,6 +2990,7 @@ plugin_enabled(const char *plugin_name, void *identity)
slapi_search_internal_pb(search_pb);
slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
if (LDAP_SUCCESS != rc) { /* plugin is not available */
+ rc = 0; /* disabled, by default */
goto bail;
}
diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c
index 9c485de..6a059b9 100644
--- a/ldap/servers/slapd/snmp_collator.c
+++ b/ldap/servers/slapd/snmp_collator.c
@@ -481,6 +481,10 @@ int snmp_collator_stop()
{
int err;
+ if (snmp_collator_stopped) {
+ return 0;
+ }
+
/* Abort any pending events */
slapi_eq_cancel(snmp_eq_ctx);
snmp_collator_stopped = 1;
@@ -506,7 +510,9 @@ int snmp_collator_stop()
sem_unlink(stats_sem_name);
/* delete lock */
- PR_DestroyLock(interaction_table_mutex);
+ if (interaction_table_mutex) {
+ PR_DestroyLock(interaction_table_mutex);
+ }
#ifdef _WIN32
/* send the event so server down trap gets set on NT */
@@ -570,6 +576,12 @@ snmp_collator_sem_wait()
int i = 0;
int got_sem = 0;
+ if (SEM_FAILED == stats_sem) {
+ LDAPDebug1Arg(LDAP_DEBUG_ANY,
+ "semaphore for stats file (%s) is not available.\n", szStatsFile);
+ return;
+ }
+
for (i=0; i < SNMP_NUM_SEM_WAITS; i++) {
if (sem_trywait(stats_sem) == 0) {
got_sem = 1;
commit 5c0a926ccbc84c70798fa4dd57193c26793d145e
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 13:21:49 2011 -0700
Bug 697027 - 8 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 8]
Description: Adding slapi_ch_free_string to free temporary variable
value; adding slapi_ch_array_free to free types_to_generate.
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index c457c0f..fc520c9 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -869,6 +869,7 @@ dna_parse_config_entry(Slapi_Entry * e, int apply)
"dna_parse_config_entry: failed to normalize dn: "
"%s\n", value);
ret = DNA_FAILURE;
+ slapi_ch_free_string(&value);
goto bail;
}
entry->shared_cfg_base = normdn;
@@ -883,6 +884,7 @@ dna_parse_config_entry(Slapi_Entry * e, int apply)
"%s=%s+%s=%s,%s", DNA_HOSTNAME,
hostname, DNA_PORTNUM, portnum, value);
ret = DNA_FAILURE;
+ slapi_ch_free_string(&value);
goto bail;
}
entry->shared_cfg_dn = normdn;
@@ -890,6 +892,7 @@ dna_parse_config_entry(Slapi_Entry * e, int apply)
slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
"----------> %s [%s]\n", DNA_SHARED_CFG_DN,
entry->shared_cfg_base);
+ slapi_ch_free_string(&value);
}
value = slapi_entry_attr_get_charptr(e, DNA_THRESHOLD);
@@ -3002,6 +3005,7 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
errstr = slapi_ch_smprintf("Allocation of a new value for
range"
" %s failed! Unable to
proceed.",
config_entry->dn);
+ slapi_ch_array_free(types_to_generate);
break;
}
@@ -3060,6 +3064,8 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
slapi_ch_free_string(&value);
slapi_ch_free_string(&new_value);
slapi_ch_array_free(types_to_generate);
+ } else if (types_to_generate) {
+ slapi_ch_free((void **)&types_to_generate);
}
next:
list = PR_NEXT_LINK(list);
commit d317718a124d2759eafbaa761914cfc9b8ffdf8b
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 13:10:01 2011 -0700
Bug 697027 - 7 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 7]
Description: Adding slapi_sdn_done to free memories held in sdn.
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index 679cbff..9670de2 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -316,6 +316,7 @@ do_bind( Slapi_PBlock *pb )
{
auto_bind = 1; /* flag the bind method */
dn = slapi_ch_strdup(pb->pb_conn->c_dn);
+ slapi_sdn_done(&sdn);
slapi_sdn_init_dn_passin(&sdn,dn);
}
}
commit 2af101b69ece052498158fd50804d843d75ef1a0
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 11:41:41 2011 -0700
Bug 697027 - 6 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 6]
Description: Moving "csn_free(&attributedeletioncsn)" to the
free_and_return section to fix the leak.
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index a4a67a6..7a015ff 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -735,6 +735,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int
read_stateinfo )
int check_for_duplicate_values =
( 0 != ( flags & SLAPI_STR2ENTRY_REMOVEDUPVALS ));
Slapi_Value *value = 0;
+ CSN *attributedeletioncsn= NULL;
CSN *maxcsn= NULL;
char *normdn = NULL;
int strict = 0;
@@ -755,13 +756,14 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int
read_stateinfo )
}
while ( (s = ldif_getline( &next )) != NULL )
{
- CSN *attributedeletioncsn= NULL;
CSNSet *valuecsnset= NULL;
int value_state= VALUE_NOTFOUND;
int attr_state= VALUE_NOTFOUND;
int freeval = 0;
struct berval bv_null = {0, NULL};
+ csn_free(&attributedeletioncsn);
+
if ( *s == '\n' || *s == '\0' ) {
break;
}
@@ -779,7 +781,6 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int
read_stateinfo )
/*
* Extract the attribute and value CSNs from the attribute type.
*/
- csn_free(&attributedeletioncsn);
csnset_free(&valuecsnset);
value_state= VALUE_NOTFOUND;
attr_state= VALUE_NOTFOUND;
@@ -792,7 +793,6 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int
read_stateinfo )
/* ignore deleted values and attributes */
/* the memory below was not allocated by the slapi_ch_ functions */
if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
- csn_free(&attributedeletioncsn);
continue;
}
/* Ignore CSNs */
@@ -848,7 +848,6 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int
read_stateinfo )
escape_string( valuecharptr, ebuf2 ), 0 );
/* the memory below was not allocated by the slapi_ch_ functions */
if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
- csn_free(&attributedeletioncsn);
continue;
}
normdn = slapi_create_dn_string("%s", valuecharptr);
@@ -863,7 +862,6 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int
read_stateinfo )
slapi_entry_set_dn(e, normdn);
/* the memory below was not allocated by the slapi_ch_ functions */
if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
- csn_free(&attributedeletioncsn);
continue;
}
@@ -873,7 +871,6 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int
read_stateinfo )
}
/* the memory below was not allocated by the slapi_ch_ functions */
if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
- csn_free(&attributedeletioncsn);
continue;
}
@@ -881,7 +878,6 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int
read_stateinfo )
if ( (flags & SLAPI_STR2ENTRY_NO_ENTRYDN) &&
strcasecmp( type, "entrydn" ) == 0 ) {
if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
- csn_free(&attributedeletioncsn);
continue;
}
@@ -898,7 +894,6 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int
read_stateinfo )
}
/* the memory below was not allocated by the slapi_ch_ functions */
if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
- csn_free(&attributedeletioncsn);
continue;
}
@@ -1028,7 +1023,6 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int
read_stateinfo )
type, valuecharptr);
slapi_entry_free( e ); e = NULL;
if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
- csn_free(&attributedeletioncsn);
goto free_and_return;
}
}
@@ -1143,7 +1137,6 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int
read_stateinfo )
/* Failure adding to value tree */
LDAPDebug( LDAP_DEBUG_ANY, "str2entry_dupcheck: unexpected failure %d
constructing value tree\n", rc, 0, 0 );
slapi_entry_free( e ); e = NULL;
- csn_free(&attributedeletioncsn);
goto free_and_return;
}
@@ -1232,6 +1225,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int
read_stateinfo )
if(sa->sa_attributedeletioncsn!=NULL)
{
attr_set_deletion_csn(*a,sa->sa_attributedeletioncsn);
+ csn_free(&sa->sa_attributedeletioncsn);
}
}
}
@@ -1284,6 +1278,7 @@ free_and_return:
}
slapi_ch_free((void **) &dyn_attrs );
if (value) slapi_value_free(&value);
+ csn_free(&attributedeletioncsn);
csn_free(&maxcsn);
LDAPDebug( LDAP_DEBUG_TRACE, "<= str2entry_dupcheck 0x%x
\"%s\"\n",
commit db1f633c95aa7ec47d477f882a90d44796e41a41
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 11:04:31 2011 -0700
Bug 697027 - 5 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 5]
Description: Adding slapi_ch_free_string to free result_matched
to operation_free.
diff --git a/ldap/servers/slapd/operation.c b/ldap/servers/slapd/operation.c
index 510b257..185723e 100644
--- a/ldap/servers/slapd/operation.c
+++ b/ldap/servers/slapd/operation.c
@@ -219,6 +219,7 @@ operation_free( Slapi_Operation **op, Connection *conn )
if ( NULL != (*op)->o_results.result_controls ) {
ldap_controls_free( (*op)->o_results.result_controls );
}
+ slapi_ch_free_string(&(*op)->o_results.result_matched);
if(operation_is_flag_set(*op, OP_FLAG_INTERNAL))
{
slapi_ch_free((void**)op);
commit 0cea6d717bfc212ca83635b3008f844b2c2e031e
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 10:54:20 2011 -0700
Bug 697027 - 4 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 4]
Description: Removing unnecessary slapi_ch_strdup calls.
Adding slapi_ch_free_string to free password, binddn, binddn2
and url to cb_instance_free.
diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c
b/ldap/servers/plugins/chainingdb/cb_instance.c
index 9a54004..e3cb932 100644
--- a/ldap/servers/plugins/chainingdb/cb_instance.c
+++ b/ldap/servers/plugins/chainingdb/cb_instance.c
@@ -214,7 +214,7 @@ static cb_backend_instance * cb_instance_alloc(cb_backend * cb, char *
name, cha
inst->monitor_availability.cpt = 0 ; /* set up the failed conn
counter to 0 */
/* create RW lock to protect the config */
- inst->rwl_config_lock = PR_NewRWLock(PR_RWLOCK_RANK_NONE, slapi_ch_strdup(name));
+ inst->rwl_config_lock = PR_NewRWLock(PR_RWLOCK_RANK_NONE, name);
/* quick hack */
/* put a ref to the config lock in the pool */
@@ -262,6 +262,10 @@ void cb_instance_free(cb_backend_instance * inst) {
{
cb_close_conn_pool(inst->pool);
slapi_destroy_condvar(inst->pool->conn.conn_list_cv);
+ slapi_ch_free_string(&inst->pool->password);
+ slapi_ch_free_string(&inst->pool->binddn);
+ slapi_ch_free_string(&inst->pool->binddn2);
+ slapi_ch_free_string(&inst->pool->url);
slapi_destroy_mutex(inst->pool->conn.conn_list_mutex);
slapi_ch_free((void **) &inst->pool);
}
@@ -1869,7 +1873,7 @@ int cb_instance_add_config_callback(Slapi_PBlock *pb, Slapi_Entry*
e, Slapi_Entr
Slapi_PBlock *aPb=NULL;
- inst->inst_be =
slapi_be_new(CB_CHAINING_BACKEND_TYPE,slapi_ch_strdup(inst->inst_name),0,0);
+ inst->inst_be =
slapi_be_new(CB_CHAINING_BACKEND_TYPE,inst->inst_name,0,0);
aPb=slapi_pblock_new();
slapi_pblock_set(aPb, SLAPI_PLUGIN, inst->backend_type->plugin);
slapi_be_setentrypoint(inst->inst_be,0,(void *)NULL,aPb);
commit 55ea40a5c4c066db00d6079437d9ca32691410f0
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 10:38:21 2011 -0700
Bug 697027 - 3 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 3]
Description: Adding slapi_counter_destroy to destroy counters
cache->c_cursize, c_hits, and c_tries used in the entry cache.
diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c
index f21cd87..e29247e 100644
--- a/ldap/servers/slapd/back-ldbm/cache.c
+++ b/ldap/servers/slapd/back-ldbm/cache.c
@@ -642,6 +642,9 @@ static void erase_cache(struct cache *cache, int type)
#ifdef UUIDCACHE_ON
slapi_ch_free((void **)&cache->c_uuidtable);
#endif
+ slapi_counter_destroy(&cache->c_cursize);
+ slapi_counter_destroy(&cache->c_hits);
+ slapi_counter_destroy(&cache->c_tries);
}
/* to be used on shutdown or when destroying a backend instance */
commit 065d051e81d677a1794fc3837bc23302eac5cc22
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 10:30:44 2011 -0700
Bug 697027 - 2 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 2]
Description: Adding slapi_ch_free_string to free inst->inst_parent_dir_name.
diff --git a/ldap/servers/slapd/back-ldbm/instance.c
b/ldap/servers/slapd/back-ldbm/instance.c
index da66565..7e5a4cd 100644
--- a/ldap/servers/slapd/back-ldbm/instance.c
+++ b/ldap/servers/slapd/back-ldbm/instance.c
@@ -381,9 +381,10 @@ ldbm_instance_destructor(void **arg)
LDAPDebug(LDAP_DEBUG_ANY, "Destructor for instance %s called\n",
inst->inst_name, 0, 0);
- slapi_ch_free((void **)&inst->inst_name);
+ slapi_ch_free_string(&inst->inst_name);
PR_DestroyLock(inst->inst_config_mutex);
- slapi_ch_free((void **)&inst->inst_dir_name);
+ slapi_ch_free_string(&inst->inst_dir_name);
+ slapi_ch_free_string(&inst->inst_parent_dir_name);
PR_DestroyLock(inst->inst_db_mutex);
PR_DestroyLock(inst->inst_handle_list_mutex);
PR_DestroyLock(inst->inst_nextid_mutex);
commit 1bc50015c9e5c693ea7d1b3120778df6ddbe0878
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 10:13:12 2011 -0700
Bug 697027 - 1 - minor memory leaks found by Valgrind + TET
https://bugzilla.redhat.com/show_bug.cgi?id=697027
[Case 1]
Description: Adding slapi_ch_free to free group_slapiattrs to
memberof_free_config. Note: attributes which addresses are
stored in group_slapiattrs are freed properly.
diff --git a/ldap/servers/plugins/memberof/memberof_config.c
b/ldap/servers/plugins/memberof/memberof_config.c
index 1a258d3..d31e690 100644
--- a/ldap/servers/plugins/memberof/memberof_config.c
+++ b/ldap/servers/plugins/memberof/memberof_config.c
@@ -471,6 +471,7 @@ memberof_free_config(MemberOfConfig *config)
{
slapi_attr_free(&config->group_slapiattrs[i]);
}
+ slapi_ch_free((void **)&config->group_slapiattrs);
slapi_ch_free_string(&config->memberof_attr);
}