scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
 |   11 +++++-
 
scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java
        |    5 +--
 vcl/source/treelist/transfer.cxx                                               
               |   16 +++-------
 3 files changed, 17 insertions(+), 15 deletions(-)

New commits:
commit c6d8778bfaa7f0914641d1dc53b2883fff10af1a
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sun Apr 7 14:54:52 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sun Apr 7 17:10:21 2024 +0200

    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.mcnam...@collabora.com>

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
+}
commit b5f5bc90d0eb736c413070a7622d7bde4a161c89
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sun Apr 7 14:33:08 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sun Apr 7 17:10:15 2024 +0200

    cid#1596238 clarify Explicit null dereferenced
    
    hopefully make coverity see this warning is bogus
    
    Change-Id: I1bf5fb9183058b18f10c5ebe34c6a887a957f578
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165870
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/vcl/source/treelist/transfer.cxx b/vcl/source/treelist/transfer.cxx
index 489d7d3d0230..1a1c4781ed22 100644
--- a/vcl/source/treelist/transfer.cxx
+++ b/vcl/source/treelist/transfer.cxx
@@ -2087,26 +2087,22 @@ Sequence<sal_Int8> TransferableDataHelper::GetSequence( 
const DataFlavor& rFlavo
     return aSeq;
 }
 
-
 bool TransferableDataHelper::GetSotStorageStream( SotClipboardFormatId 
nFormat, std::unique_ptr<SvStream>& rxStream ) const
 {
     DataFlavor aFlavor;
     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && 
GetSotStorageStream( aFlavor, rxStream ) );
 }
 
-
 bool TransferableDataHelper::GetSotStorageStream( const DataFlavor& rFlavor, 
std::unique_ptr<SvStream>& rxStream ) const
 {
     Sequence<sal_Int8> aSeq = GetSequence(rFlavor, OUString());
+    if (!aSeq.hasElements())
+        return false;
 
-    if (aSeq.hasElements())
-    {
-        rxStream = SotTempStream::Create( "" );
-        rxStream->WriteBytes( aSeq.getConstArray(), aSeq.getLength() );
-        rxStream->Seek( 0 );
-    }
-
-    return aSeq.hasElements();
+    rxStream = SotTempStream::Create( "" );
+    rxStream->WriteBytes( aSeq.getConstArray(), aSeq.getLength() );
+    rxStream->Seek(0);
+    return true;
 }
 
 Reference<XInputStream> TransferableDataHelper::GetInputStream( 
SotClipboardFormatId nFormat, const OUString& rDestDoc ) const

Reply via email to