Skip to content

Commit 004e0cb

Browse files
karuturiDaanHoogland
authored andcommitted
Fixed ResouceLeak on pstmtCidr in the function Upgrade430to440.moveCidrsToTheirOwnTable as reported by coverity
Fixed another leak which might occur due to outer while loop. Signed-off-by: Daan Hoogland <daan@onecht.net>
1 parent 9fd0655 commit 004e0cb

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ private void moveCidrsToTheirOwnTable(Connection conn) {
242242
pstmtItem = conn.prepareStatement(networkAclItemSql);
243243
rsItems = pstmtItem.executeQuery();
244244

245+
String networkAclItemCidrSql = "INSERT INTO `cloud`.`network_acl_item_cidrs` (network_acl_item_id, cidr) VALUES (?,?)";
246+
pstmtCidr = conn.prepareStatement(networkAclItemCidrSql);
247+
245248
// for each network acl item
246249
while(rsItems.next()) {
247250
long itemId = rsItems.getLong(1);
@@ -251,8 +254,6 @@ private void moveCidrsToTheirOwnTable(Connection conn) {
251254
// split it
252255
String[] cidrArray = cidrList.split(",");
253256
// insert a record per cidr
254-
String networkAclItemCidrSql = "INSERT INTO `cloud`.`network_acl_item_cidrs` (network_acl_item_id, cidr) VALUES (?,?)";
255-
pstmtCidr = conn.prepareStatement(networkAclItemCidrSql);
256257
pstmtCidr.setLong(1, itemId);
257258
for (String cidr : cidrArray) {
258259
pstmtCidr.setString(2, cidr);

0 commit comments

Comments
 (0)