[Libreoffice-commits] core.git: 2 commits - desktop/source scripting/java
Caolán McNamara
caolanm at redhat.com
Sun May 15 12:01:41 UTC 2016
desktop/source/lib/init.cxx | 3 -
scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java | 25 +++++-----
scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java | 25 +++++-----
3 files changed, 28 insertions(+), 25 deletions(-)
New commits:
commit 49cdc1da7660328d64a964fbc26611bf8ce158aa
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sun May 15 12:47:48 2016 +0100
coverity#1361587 Dereference null return value
and
coverity#1361588 Dereference null return value
Change-Id: Ia282c37e94d9d4131d18b3ccf6a8b7cb12c12344
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
index 5c8bd6a..c432007 100644
--- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
@@ -69,24 +69,25 @@ public class ScriptEditorForBeanShell implements ScriptEditor, ActionListener {
// try to load the template for BeanShell scripts
static {
+ BSHTEMPLATE = "// BeanShell script";
try {
URL url = ScriptEditorForBeanShell.class.getResource("template.bsh");
- InputStream in = url.openStream();
- StringBuilder buf = new StringBuilder();
- byte[] b = new byte[1024];
- int len;
-
- while ((len = in.read(b)) != -1) {
- buf.append(new String(b, 0, len));
- }
+ if (url != null) {
+ InputStream in = url.openStream();
+ StringBuilder buf = new StringBuilder();
+ byte[] b = new byte[1024];
+ int len;
+
+ while ((len = in.read(b)) != -1) {
+ buf.append(new String(b, 0, len));
+ }
- in.close();
+ in.close();
- BSHTEMPLATE = buf.toString();
+ BSHTEMPLATE = buf.toString();
+ }
} catch (IOException ioe) {
- BSHTEMPLATE = "// BeanShell script";
} catch (Exception e) {
- BSHTEMPLATE = "// BeanShell script";
}
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
index 755086d..a43abc2 100644
--- a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
+++ b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
@@ -55,24 +55,25 @@ public class ScriptEditorForJavaScript implements ScriptEditor {
HashMap<String, ScriptEditorForJavaScript>();
static {
+ JSTEMPLATE = "// JavaScript script";
try {
URL url = ScriptEditorForJavaScript.class.getResource("template.js");
- InputStream in = url.openStream();
- StringBuilder buf = new StringBuilder();
- byte[] b = new byte[1024];
- int len;
-
- while ((len = in.read(b)) != -1) {
- buf.append(new String(b, 0, len));
- }
+ if (url != null) {
+ InputStream in = url.openStream();
+ StringBuilder buf = new StringBuilder();
+ byte[] b = new byte[1024];
+ int len;
+
+ while ((len = in.read(b)) != -1) {
+ buf.append(new String(b, 0, len));
+ }
- in.close();
+ in.close();
- JSTEMPLATE = buf.toString();
+ JSTEMPLATE = buf.toString();
+ }
} catch (IOException ioe) {
- JSTEMPLATE = "// JavaScript script";
} catch (Exception e) {
- JSTEMPLATE = "// JavaScript script";
}
}
commit e141017c686c4fb1dbd3533dffff396f62f103f7
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sun May 15 12:43:02 2016 +0100
coverity#1361589 Resource leak
this is the pattern used everywhere else.
Change-Id: I18bdb43203bae8b9e36d59b4c457aa2087fdc117
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ad393e6..09f6883 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1188,7 +1188,8 @@ public:
std::stringstream aStream;
boost::property_tree::write_json(aStream, aTree);
- mpCallback->queue(LOK_CALLBACK_UNO_COMMAND_RESULT, strdup(aStream.str().c_str()));
+ OString aPayload = aStream.str().c_str();
+ mpCallback->queue(LOK_CALLBACK_UNO_COMMAND_RESULT, aPayload.getStr());
}
virtual void SAL_CALL disposing(const css::lang::EventObject&) throw (css::uno::RuntimeException, std::exception) override {}
More information about the Libreoffice-commits
mailing list