[Libreoffice-commits] core.git: swext/mediawiki

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 22 13:44:10 UTC 2021


 swext/mediawiki/src/com/sun/star/wiki/Helper.java      |   50 +++++++++--------
 swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java |   38 +++++++-----
 2 files changed, 50 insertions(+), 38 deletions(-)

New commits:
commit 3f837a85191a646e2fd14a8871c0f74b28d5714e
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Mar 22 10:31:53 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Mar 22 14:43:22 2021 +0100

    cid#1473739 Resource leak on an exceptional path
    
    and
    
    cid#1474111 Resource leak on an exceptional path
    
    Change-Id: Iea50865f975b9b8281da78b2dc63ff43bcb07c2d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112876
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/swext/mediawiki/src/com/sun/star/wiki/Helper.java b/swext/mediawiki/src/com/sun/star/wiki/Helper.java
index bde53b39f89c..4a5ec943ad8c 100644
--- a/swext/mediawiki/src/com/sun/star/wiki/Helper.java
+++ b/swext/mediawiki/src/com/sun/star/wiki/Helper.java
@@ -783,30 +783,36 @@ public class Helper
                 connPost.connect();
 
                 OutputStreamWriter post = new OutputStreamWriter(connPost.getOutputStream(), "UTF-8");
-                post.write("wpName=");
-                post.write(URLEncoder.encode(sWikiUser, "UTF-8"));
-                post.write("&wpRemember=1");
-                post.write("&wpPassword=");
-                post.write(URLEncoder.encode(sWikiPass, "UTF-8"));
-
-                if (sLoginToken.length() > 0) {
-                    post.write("&wpLoginToken=");
-                    post.write(URLEncoder.encode(sLoginToken, "UTF-8"));
-                }
+                try
+                {
+                    post.write("wpName=");
+                    post.write(URLEncoder.encode(sWikiUser, "UTF-8"));
+                    post.write("&wpRemember=1");
+                    post.write("&wpPassword=");
+                    post.write(URLEncoder.encode(sWikiPass, "UTF-8"));
+
+                    if (sLoginToken.length() > 0) {
+                        post.write("&wpLoginToken=");
+                       post.write(URLEncoder.encode(sLoginToken, "UTF-8"));
+                    }
 
-                String[][] pArgs = GetSpecialArgs( xContext, aMainURL.getHost() );
-                if ( pArgs != null )
-                    for ( int nArgInd = 0; nArgInd < pArgs.length; nArgInd++ )
-                        if ( pArgs[nArgInd].length == 2 && pArgs[nArgInd][0] != null && pArgs[nArgInd][1] != null )
-                        {
-                            post.write("&");
-                            post.write(URLEncoder.encode(pArgs[nArgInd][0], "UTF-8"));
-                            post.write("=");
-                            post.write(URLEncoder.encode(pArgs[nArgInd][0], "UTF-8"));
-                        }
+                    String[][] pArgs = GetSpecialArgs( xContext, aMainURL.getHost() );
+                    if ( pArgs != null )
+                        for ( int nArgInd = 0; nArgInd < pArgs.length; nArgInd++ )
+                            if ( pArgs[nArgInd].length == 2 && pArgs[nArgInd][0] != null && pArgs[nArgInd][1] != null )
+                            {
+                                post.write("&");
+                                post.write(URLEncoder.encode(pArgs[nArgInd][0], "UTF-8"));
+                                post.write("=");
+                               post.write(URLEncoder.encode(pArgs[nArgInd][0], "UTF-8"));
+                           }
 
-                post.flush();
-                post.close();
+                    post.flush();
+                }
+                finally
+                {
+                    post.close();
+                }
 
                 nResultCode = connPost.getResponseCode();
 
diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java b/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java
index a576ef9c732e..5c22afa2a651 100644
--- a/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java
+++ b/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java
@@ -205,23 +205,29 @@ public class WikiArticle
             connPost.connect();
 
             OutputStreamWriter post = new OutputStreamWriter(connPost.getOutputStream(), "UTF-8");
-            post.write("wpTextbox1=");
-            post.write(URLEncoder.encode(sWikiCode, "UTF-8"));
-            post.write("&wpSummary=");
-            post.write(URLEncoder.encode(sWikiComment, "UTF-8"));
-            post.write("&wpSection=");
-            post.write("&wpEdittime=");
-            post.write(URLEncoder.encode(m_sEditTime, "UTF-8"));
-            post.write("&wpSave=Save%20page");
-            post.write("&wpEditToken=");
-            post.write(URLEncoder.encode(m_sEditToken, "UTF-8"));
-
-            if (bMinorEdit) {
-                post.write("&wpMinoredit=1");
-            }
+            try
+            {
+                post.write("wpTextbox1=");
+                post.write(URLEncoder.encode(sWikiCode, "UTF-8"));
+                post.write("&wpSummary=");
+                post.write(URLEncoder.encode(sWikiComment, "UTF-8"));
+                post.write("&wpSection=");
+                post.write("&wpEdittime=");
+                post.write(URLEncoder.encode(m_sEditTime, "UTF-8"));
+                post.write("&wpSave=Save%20page");
+                post.write("&wpEditToken=");
+                post.write(URLEncoder.encode(m_sEditToken, "UTF-8"));
+
+                if (bMinorEdit) {
+                    post.write("&wpMinoredit=1");
+                }
 
-            post.flush();
-            post.close();
+                post.flush();
+            }
+            finally
+            {
+                post.close();
+            }
 
             int nResultCode = connPost.getResponseCode();
             if ( nResultCode < 400 )


More information about the Libreoffice-commits mailing list