[Libreoffice-commits] core.git: 2 commits - cppu/source vcl/generic

Caolán McNamara caolanm at redhat.com
Fri Nov 14 08:50:03 PST 2014


 cppu/source/typelib/static_types.cxx |    4 +---
 vcl/generic/fontmanager/parseAFM.cxx |   21 +++++++++------------
 2 files changed, 10 insertions(+), 15 deletions(-)

New commits:
commit 3d876661857b68cafde16fafd5f280cc78b3e52b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 16:43:10 2014 +0000

    coverity#704593 silence Dereference after null check
    
    Change-Id: I3ccd6895a1ddbf46a441e60ceaaaceb945f682e4

diff --git a/cppu/source/typelib/static_types.cxx b/cppu/source/typelib/static_types.cxx
index 13d2e85..fb99775 100644
--- a/cppu/source/typelib/static_types.cxx
+++ b/cppu/source/typelib/static_types.cxx
@@ -277,7 +277,6 @@ CPPU_DLLPUBLIC typelib_TypeDescriptionReference ** SAL_CALL typelib_static_type_
     return &s_aTypes[eTypeClass];
 }
 
-
 CPPU_DLLPUBLIC void SAL_CALL typelib_static_type_init(
     typelib_TypeDescriptionReference ** ppRef,
     typelib_TypeClass eTypeClass, const sal_Char * pTypeName )
@@ -291,13 +290,12 @@ CPPU_DLLPUBLIC void SAL_CALL typelib_static_type_init(
             OUString aTypeName( OUString::createFromAscii( pTypeName ) );
             ::typelib_typedescriptionreference_new( ppRef, eTypeClass, aTypeName.pData );
 
-            // another static ref:
+            // coverity[var_deref_op] - another static ref
             ++((*ppRef)->nStaticRefCount);
         }
     }
 }
 
-
 CPPU_DLLPUBLIC void SAL_CALL typelib_static_sequence_type_init(
     typelib_TypeDescriptionReference ** ppRef,
     typelib_TypeDescriptionReference * pElementType )
commit 7d9b6119495bf1ca04cfe7b413cf165f347d0ec5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 15:31:31 2014 +0000

    coverity#706217 Time of check time of use
    
    Change-Id: I762658a01e97f56b2f9362a38a0fefc941698d1b

diff --git a/vcl/generic/fontmanager/parseAFM.cxx b/vcl/generic/fontmanager/parseAFM.cxx
index 24345d2..13cdca7 100644
--- a/vcl/generic/fontmanager/parseAFM.cxx
+++ b/vcl/generic/fontmanager/parseAFM.cxx
@@ -112,24 +112,21 @@ class FileInputStream
     }
 };
 
-FileInputStream::FileInputStream( const char* pFilename ) :
-    m_pMemory( NULL ),
-    m_nPos( 0 ),
-    m_nLen( 0 )
+FileInputStream::FileInputStream(const char* pFilename)
+    : m_pMemory(NULL)
+    , m_nPos(0)
+    , m_nLen(0)
 {
-    struct stat aStat;
-    if( ! stat( pFilename, &aStat ) &&
-        S_ISREG( aStat.st_mode )    &&
-        aStat.st_size > 0
-      )
+    FILE* fp = fopen( pFilename, "r" );
+    if( fp )
     {
-        FILE* fp = fopen( pFilename, "r" );
-        if( fp )
+        struct stat aStat;
+        if (!fstat(fileno(fp), &aStat) && S_ISREG(aStat.st_mode) && aStat.st_size > 0)
         {
             m_pMemory = (char*)rtl_allocateMemory( aStat.st_size );
             m_nLen = (unsigned int)fread( m_pMemory, 1, aStat.st_size, fp );
-            fclose( fp );
         }
+        fclose( fp );
     }
 }
 


More information about the Libreoffice-commits mailing list