diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-02-06 20:39:44 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-02-06 20:58:44 +0000 |
commit | 2b198c3380ccf07aa981a055eff698e1482028c8 (patch) | |
tree | 323605f05155afb351fced2a2c1563c405a16c43 /swext/mediawiki/src | |
parent | 8998768a34751d35403678a81464a26835b2230e (diff) |
coverity#1326498 Resource leak on an exceptional path
Change-Id: I28b848ef94039e4c79242599b2031b8789857a46
Diffstat (limited to 'swext/mediawiki/src')
-rw-r--r-- | swext/mediawiki/src/com/sun/star/wiki/Helper.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/swext/mediawiki/src/com/sun/star/wiki/Helper.java b/swext/mediawiki/src/com/sun/star/wiki/Helper.java index 020889965e6a..8b781cc8c341 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/Helper.java +++ b/swext/mediawiki/src/com/sun/star/wiki/Helper.java @@ -348,15 +348,25 @@ public class Helper return sURL; } + private static void close(BufferedReader c) { + if (c == null) return; + try { + c.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + protected static String EachLine( String sURL ) { String sText = ""; + BufferedReader aBufReader = null; try { URL aURL = new URL( sURL ); File aFile = new File( aURL.getFile() ); InputStreamReader aInputReader = new InputStreamReader( new FileInputStream( aFile ), "UTF-8" ); - BufferedReader aBufReader = new BufferedReader( aInputReader ); + aBufReader = new BufferedReader( aInputReader ); StringBuffer aBuf = new StringBuffer(); String sEachLine = aBufReader.readLine(); @@ -371,10 +381,12 @@ public class Helper sText = aBuf.toString(); aBufReader.close(); - } catch ( Exception e ) - { + } catch ( Exception e ) { e.printStackTrace(); } + finally { + close(aBufReader); + } return sText; } |