summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-04-07 14:54:52 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-04-07 17:10:21 +0200
commitc6d8778bfaa7f0914641d1dc53b2883fff10af1a (patch)
treea202d93e32f5ab3f47717dc016a00caae32f7868 /scripting
parentb5f5bc90d0eb736c413070a7622d7bde4a161c89 (diff)
cid#1596251 Dereference null return value
and cid#1596249 Dereference null return value Change-Id: I2d50e8be5ec20001527c20ccd46a9a0336792d8e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165871 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'scripting')
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java11
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java5
2 files changed, 11 insertions, 5 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 0ab265ecc799..5abb761ba954 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
@@ -342,11 +342,16 @@ public class ScriptEditorForBeanShell extends ScriptEditorBase implements Action
String s = view.getText();
fos = scriptURL.openConnection().getOutputStream();
- if (fos != null) {
+ if (fos != null && s != null) {
fos.write(s.getBytes());
} else {
- showErrorMessage(
- "Error saving script: Could not open stream for file");
+ if (fos == null) {
+ showErrorMessage(
+ "Error saving script: Could not open stream for file");
+ } else {
+ showErrorMessage(
+ "Error saving script: Could not get script text");
+ }
result = false;
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java
index 165f00844d70..ff94d16d8ca0 100644
--- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java
@@ -109,7 +109,8 @@ public class ScriptSourceModel {
Object result;
if (view.isModified()) {
- result = interpreter.eval(view.getText());
+ String s = view.getText();
+ result = interpreter.eval(s != null ? s : "");
} else {
result = interpreter.eval(getText());
}
@@ -122,4 +123,4 @@ public class ScriptSourceModel {
currentPosition = lineNum - 1;
view.update();
}
-} \ No newline at end of file
+}