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>
This commit is contained in:
Caolán McNamara 2024-04-07 14:54:52 +01:00
parent b5f5bc90d0
commit c6d8778bfa
2 changed files with 11 additions and 5 deletions

View file

@ -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;
}

View file

@ -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();
}
}
}