diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-03-22 10:31:53 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-03-22 14:43:22 +0100 |
commit | 3f837a85191a646e2fd14a8871c0f74b28d5714e (patch) | |
tree | 04bbeff9164bc72f2fdb58e09c090fa6659f6492 /swext | |
parent | 3c4089e80504dfc1a1bb53b478394df2f788cc85 (diff) |
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@redhat.com>
Diffstat (limited to 'swext')
-rw-r--r-- | swext/mediawiki/src/com/sun/star/wiki/Helper.java | 50 | ||||
-rw-r--r-- | swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java | 38 |
2 files changed, 50 insertions, 38 deletions
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 ) |