diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-05-15 12:47:48 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-05-15 12:47:48 +0100 |
commit | 49cdc1da7660328d64a964fbc26611bf8ce158aa (patch) | |
tree | 2462d9f22ac72470b5d8873a74a943decf8cb4be /scripting | |
parent | e141017c686c4fb1dbd3533dffff396f62f103f7 (diff) |
coverity#1361587 Dereference null return value
and
coverity#1361588 Dereference null return value
Change-Id: Ia282c37e94d9d4131d18b3ccf6a8b7cb12c12344
Diffstat (limited to 'scripting')
2 files changed, 26 insertions, 24 deletions
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 5c8bd6af0624..c43200744e15 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 755086d4daf2..a43abc25f7cd 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"; } } |