diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-03-04 10:13:12 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-03-04 11:24:27 +0000 |
commit | 1e83fab9b47dc34129035ca1660a27c6a00b15d9 (patch) | |
tree | cd3c996b4b7f6cf1c076e3a5f1173473f004459d /xmerge | |
parent | b08e200c3dfa964f257c8b7719ef9c801fb107d7 (diff) |
coverity#1326516 Resource leak on an exceptional path
Change-Id: I91cc5614fb0db76eabd46cbe7e39ae33227728b7
Diffstat (limited to 'xmerge')
-rw-r--r-- | xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java index 9d3ae7cb00a7..506b754b3a7c 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java @@ -184,12 +184,16 @@ public final class Driver { Document convertedFile = (Document)mergeDocEnum.next(); merger.merge(convertedFile); - mergeIS.close(); + mergeIS.close(); - FileOutputStream fos = new FileOutputStream(mergeFile); - mergeDoc.write(fos); - fos.flush(); - fos.close(); + FileOutputStream fos = null; + try { + fos = new FileOutputStream(mergeFile); + mergeDoc.write(fos); + fos.flush(); + } finally { + close(fos); + } } catch (Exception mergeExcept) { System.out.println("\nThere was an error in the merge"); mergeExcept.printStackTrace(); |