[Libreoffice-commits] core.git: sal/osl

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Sun Apr 28 18:28:31 UTC 2019


 sal/osl/all/filepath.cxx |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 0578353a4d602805124fb642c7051d99f55e4599
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun Apr 28 15:30:42 2019 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun Apr 28 20:27:48 2019 +0200

    tdf#120703 PVS: dereference before nullptr check
    
    V595 The 'ustrFile' pointer was utilized before it was verified against nullptr.
         Check lines: 83, 107.
    
    Change-Id: I874983508fb805b1f0a55b3a5b6d4d78ae1babdb
    Reviewed-on: https://gerrit.libreoffice.org/71472
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sal/osl/all/filepath.cxx b/sal/osl/all/filepath.cxx
index 7e8022f4f9e8..ae917c6d90ed 100644
--- a/sal/osl/all/filepath.cxx
+++ b/sal/osl/all/filepath.cxx
@@ -19,6 +19,7 @@
 
 #include <osl/file.h>
 #include <rtl/ustring.h>
+#include <cassert>
 
 static sal_uInt32 osl_defCalcTextWidth( rtl_uString *ustrText )
 {
@@ -49,6 +50,8 @@ oslFileError SAL_CALL osl_abbreviateSystemPath( rtl_uString *ustrSystemPath, rtl
         }
     }
 
+    assert(ustrPath && ustrFile);
+
     uPathWidth = pfnCalcWidth( ustrPath );
     uFileWidth = pfnCalcWidth( ustrFile );
 
@@ -101,11 +104,8 @@ oslFileError SAL_CALL osl_abbreviateSystemPath( rtl_uString *ustrSystemPath, rtl
         uPathWidth = pfnCalcWidth( *pustrCompacted );
     }
 
-    if ( ustrPath )
-        rtl_uString_release( ustrPath );
-
-    if ( ustrFile )
-        rtl_uString_release( ustrFile );
+    rtl_uString_release(ustrPath);
+    rtl_uString_release(ustrFile);
 
     return osl_File_E_None;
 }


More information about the Libreoffice-commits mailing list