[Libreoffice-commits] core.git: 4 commits - swext/mediawiki wizards/com xmerge/source

Caolán McNamara caolanm at redhat.com
Sat Feb 6 20:59:08 UTC 2016


 swext/mediawiki/src/com/sun/star/wiki/Helper.java                           |   18 ++++++++--
 wizards/com/sun/star/wizards/text/TextDocument.java                         |    1 
 xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java |    9 +++--
 xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java            |   15 +++++++-
 4 files changed, 35 insertions(+), 8 deletions(-)

New commits:
commit 77c3b539e1fa50ebd8c6ebfd53888e6f7dd609ac
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Feb 6 20:51:08 2016 +0000

    coverity#1326633 DE: Dropped or ignored exception
    
    this is probably good enough
    
    Change-Id: I37304004f78d245ee0f400f07d07c731351d79eb

diff --git a/wizards/com/sun/star/wizards/text/TextDocument.java b/wizards/com/sun/star/wizards/text/TextDocument.java
index c6dace7..74a24eb 100644
--- a/wizards/com/sun/star/wizards/text/TextDocument.java
+++ b/wizards/com/sun/star/wizards/text/TextDocument.java
@@ -124,6 +124,7 @@ public class TextDocument
         {
             // TODO: it seems the whole project does not really have an error handling. Other methods
             // seem to generally silence errors, so we can't do anything else here...
+            e.printStackTrace();
         }
 
         if (bShowStatusIndicator)
commit f5d2efb75720741f76997600662354d432faa6d1
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Feb 6 20:49:16 2016 +0000

    coverity#1326525 Resource leak on an exceptional path
    
    Change-Id: I391367ec055372cc82ddb21d19e53041da91b4f6

diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java
index 6868675..3c9caf1 100644
--- a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java
+++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java
@@ -59,8 +59,11 @@ public class ConverterInfoList {
         InputStream is          = c.getResourceAsStream(propsFile);
         BufferedInputStream bis = new BufferedInputStream(is);
         Properties        props = new Properties();
-        props.load(bis);
-        bis.close();
+        try {
+            props.load(bis);
+        } finally {
+            bis.close();
+        }
 
         int i              = 1;
         String jarFileName = "";
@@ -85,4 +88,4 @@ public class ConverterInfoList {
 
         return jars.iterator();
     }
-}
\ No newline at end of file
+}
commit d9442b1398117ee1710a608a7c30d5e1a073a945
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Feb 6 20:46:09 2016 +0000

    coverity#1326516 Resource leak on an exceptional path
    
    Change-Id: Ia46ec73bd3dcaef1ec0c9a977f3fc472d94ed390

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 7e97033..9d3ae7c 100644
--- a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java
+++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java
@@ -100,6 +100,15 @@ public final class Driver {
         }
     }
 
+    private static void close(FileOutputStream c) {
+        if (c == null) return;
+        try {
+            c.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     /**
      * Gets a {@code Convert} object using the {@code ConverterFactory} and does
      * the conversion using this object.
@@ -153,15 +162,17 @@ public final class Driver {
                 while (docEnum.hasNext()) {
                     Document docOut      = (Document)docEnum.next();
                     String fileName      = docOut.getFileName();
+                    FileOutputStream fos = null;
                     try {
-                        FileOutputStream fos = new FileOutputStream(fileName);
+                        fos = new FileOutputStream(fileName);
                         docOut.write(fos);
                         fos.flush();
-                        fos.close();
                     } catch (Exception writeExcept) {
                         System.out.println("\nThere was an writing out file <" +
                             fileName + ">");
                         writeExcept.printStackTrace();
+                    } finally {
+                        close(fos);
                     }
                 }
             } else {
commit 2b198c3380ccf07aa981a055eff698e1482028c8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Feb 6 20:39:44 2016 +0000

    coverity#1326498 Resource leak on an exceptional path
    
    Change-Id: I28b848ef94039e4c79242599b2031b8789857a46

diff --git a/swext/mediawiki/src/com/sun/star/wiki/Helper.java b/swext/mediawiki/src/com/sun/star/wiki/Helper.java
index 0208899..8b781cc 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;
     }
 


More information about the Libreoffice-commits mailing list