1
0
Эх сурвалжийг харах

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".
Noriko Hosoi 14 жил өмнө
parent
commit
be34548e9d

+ 1 - 0
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;
 	}
 

+ 13 - 1
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;