summaryrefslogtreecommitdiffstats
path: root/ldap/servers/plugins/replication/windows_connection.c
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2010-07-20 22:08:40 -0500
committerNoriko Hosoi <nhosoi@redhat.com>2010-08-19 16:58:31 -0700
commit72a2c1e7699af16d9617159fe7677a33fdf7b6f8 (patch)
tree6eb8d8c5e236f0b36dc42c77e20b982aa7c40712 /ldap/servers/plugins/replication/windows_connection.c
parent92ee0f56c4bdbef67c88b39f0203c36982191fb7 (diff)
downloadds-72a2c1e7699af16d9617159fe7677a33fdf7b6f8.tar.gz
ds-72a2c1e7699af16d9617159fe7677a33fdf7b6f8.tar.xz
ds-72a2c1e7699af16d9617159fe7677a33fdf7b6f8.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 12052 description: Fixed resource leaks in windows_conn_connect().
Diffstat (limited to 'ldap/servers/plugins/replication/windows_connection.c')
-rw-r--r--ldap/servers/plugins/replication/windows_connection.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/ldap/servers/plugins/replication/windows_connection.c b/ldap/servers/plugins/replication/windows_connection.c
index acee8083..5eab68d5 100644
--- a/ldap/servers/plugins/replication/windows_connection.c
+++ b/ldap/servers/plugins/replication/windows_connection.c
@@ -1148,7 +1148,7 @@ windows_conn_connect(Repl_Connection *conn)
int optdata;
int secure = 0;
char* binddn = NULL;
- struct berval *creds;
+ struct berval *creds = NULL;
ConnResult return_value = CONN_OPERATION_SUCCESS;
int pw_ret = 1;
@@ -1156,8 +1156,7 @@ windows_conn_connect(Repl_Connection *conn)
/** Connection already open just return SUCCESS **/
if(conn->state == STATE_CONNECTED) {
- LDAPDebug( LDAP_DEBUG_TRACE, "<= windows_conn_connect\n", 0, 0, 0 );
- return return_value;
+ goto done;
}
PR_Lock(conn->lock);
@@ -1196,8 +1195,7 @@ windows_conn_connect(Repl_Connection *conn)
return_value = CONN_OPERATION_FAILED;
conn->last_ldap_error = LDAP_INVALID_CREDENTIALS;
conn->state = STATE_DISCONNECTED;
- LDAPDebug( LDAP_DEBUG_TRACE, "<= windows_conn_connect\n", 0, 0, 0 );
- return (return_value);
+ goto done;
} /* Else, does not mean that the plain is correct, only means the we had no internal
decoding pb */
conn->plain = slapi_ch_strdup (plain);
@@ -1220,11 +1218,10 @@ windows_conn_connect(Repl_Connection *conn)
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: SSL Not Initialized, Replication over SSL FAILED\n",
agmt_get_long_name(conn->agmt));
+ return_value = CONN_SSL_NOT_ENABLED;
conn->last_ldap_error = LDAP_INAPPROPRIATE_AUTH;
conn->last_operation = CONN_INIT;
- ber_bvfree(creds);
- creds = NULL;
- return CONN_SSL_NOT_ENABLED;
+ goto done;
}
}
@@ -1252,10 +1249,7 @@ windows_conn_connect(Repl_Connection *conn)
agmt_get_long_name(conn->agmt),
secure ? "secure " : "",
(secure == 2) ? "startTLS " : "");
- ber_bvfree(creds);
- creds = NULL;
- LDAPDebug( LDAP_DEBUG_TRACE, "<= windows_conn_connect\n", 0, 0, 0 );
- return return_value;
+ goto done;
}
/* slapi_ch_strdup is OK with NULL strings */
@@ -1326,9 +1320,6 @@ windows_conn_connect(Repl_Connection *conn)
}
}
- ber_bvfree(creds);
- creds = NULL;
-
slapi_ch_free((void**)&binddn);
if(return_value == CONN_OPERATION_FAILED)
@@ -1340,6 +1331,12 @@ windows_conn_connect(Repl_Connection *conn)
conn->state = STATE_CONNECTED;
}
+done:
+ if (creds) {
+ ber_bvfree(creds);
+ creds = NULL;
+ }
+
LDAPDebug( LDAP_DEBUG_TRACE, "<= windows_conn_connect\n", 0, 0, 0 );
return return_value;
}