Repository: cloudstack
Updated Branches:
refs/heads/4.3 ba9ae0c66 -> 44c8e1f67
COVERITY: Fixed Resource leak (RESOURCE_LEAK) 11.
overwrite_var: Overwriting "pstmt" in "pstmt = conn.prepareStatement("INSERT
INTO `cloud`.`ldap_configuration`(hostname, port) VALUES(?,?)")" leaks the
resource that "pstmt" refers to.
Signed-off-by: Sebastien Goasguen <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/44c8e1f6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/44c8e1f6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/44c8e1f6
Branch: refs/heads/4.3
Commit: 44c8e1f67f67827a29ece43e993c6b661adebe0c
Parents: ba9ae0c
Author: Rajani Karuturi <[email protected]>
Authored: Tue Jun 3 16:11:01 2014 +0530
Committer: Sebastien Goasguen <[email protected]>
Committed: Wed Jul 2 16:05:09 2014 +0200
----------------------------------------------------------------------
engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/44c8e1f6/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
b/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
index 7e26132..889cad4 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
@@ -130,18 +130,20 @@ public class Upgrade421to430 implements DbUpgrade {
try {
+ pstmt = conn.prepareStatement(insertSql);
for (String[] ldapParam : ldapParams) {
String name = ldapParam[0];
String value = ldapParam[1];
String desc = ldapParam[2];
String encryptedValue = DBEncryptionUtil.encrypt(value);
- pstmt = conn.prepareStatement(insertSql);
pstmt.setString(1, name);
pstmt.setBytes(2, encryptedValue.getBytes("UTF-8"));
pstmt.setString(3, desc);
pstmt.executeUpdate();
}
+ pstmt.close();
+
/**
* if encrypted, decrypt the ldap hostname and port and then
update as they are not encrypted now.
*/
@@ -154,6 +156,8 @@ public class Upgrade421to430 implements DbUpgrade {
hostname = DBEncryptionUtil.decrypt(resultSet.getString(1));
}
+ pstmt.close();
+
pstmt = conn.prepareStatement("SELECT conf.value FROM
`cloud`.`configuration` conf WHERE conf.name='ldap.port'");
resultSet = pstmt.executeQuery();
if (resultSet.next()) {
@@ -162,6 +166,7 @@ public class Upgrade421to430 implements DbUpgrade {
portNumber = Integer.valueOf(port);
}
}
+ pstmt.close();
if (StringUtils.isNotBlank(hostname)) {
pstmt = conn.prepareStatement("INSERT INTO
`cloud`.`ldap_configuration`(hostname, port) VALUES(?,?)");
@@ -172,6 +177,7 @@ public class Upgrade421to430 implements DbUpgrade {
pstmt.setNull(2, Types.INTEGER);
}
pstmt.executeUpdate();
+ pstmt.close();
}
} catch (SQLException e) {