[Libreoffice-commits] core.git: 3 commits - desktop/unx sd/source vcl/source

Caolán McNamara caolanm at redhat.com
Fri May 6 16:16:39 UTC 2016


 desktop/unx/source/pagein.c              |   20 +++++++++-----------
 sd/source/ui/sidebar/SlideBackground.cxx |   14 ++++++++------
 vcl/source/gdi/mapmod.cxx                |    3 ++-
 3 files changed, 19 insertions(+), 18 deletions(-)

New commits:
commit 77ba88a0beaa78024ef29b8879edce0b7371ad9e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 6 17:15:32 2016 +0100

    coverity#1359231 Unchecked dynamic_cast
    
    and
    
    coverity#1359232 Unchecked dynamic_cast
    
    Change-Id: I416e9156c6f3b1a933d6d664a992420067b68d1b

diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx
index 370aade..6f0cf41 100644
--- a/sd/source/ui/sidebar/SlideBackground.cxx
+++ b/sd/source/ui/sidebar/SlideBackground.cxx
@@ -162,8 +162,8 @@ void SlideBackground::Initialize()
     mpPaperOrientation->SetSelectHdl(LINK(this,SlideBackground,PaperOrientationModifyHdl));
 
     ::sd::DrawDocShell* pDocSh = dynamic_cast<::sd::DrawDocShell*>( SfxObjectShell::Current() );
-    SdDrawDocument* pDoc = pDocSh->GetDoc();
-    sal_uInt16 nCount = pDoc->GetMasterPageCount();
+    SdDrawDocument* pDoc = pDocSh ? pDocSh->GetDoc() : nullptr;
+    sal_uInt16 nCount = pDoc ? pDoc->GetMasterPageCount() : 0;
     for( sal_uInt16 nLayout = 0; nLayout < nCount; nLayout++ )
     {
         SdPage* pMaster = static_cast<SdPage*>(pDoc->GetMasterPage(nLayout));
@@ -539,18 +539,20 @@ IMPL_LINK_NOARG_TYPED(SlideBackground, FillBackgroundHdl, ListBox&, void)
 IMPL_LINK_NOARG_TYPED(SlideBackground, AssignMasterPage, ListBox&, void)
 {
     ::sd::DrawDocShell* pDocSh = dynamic_cast<::sd::DrawDocShell*>( SfxObjectShell::Current() );
-    SdDrawDocument* mpDoc = pDocSh->GetDoc();
+    SdDrawDocument* pDoc = pDocSh ? pDocSh->GetDoc() : nullptr;
+    if (!pDoc)
+        return;
     sal_uInt16 nSelectedPage = SDRPAGE_NOTFOUND;
-    for( sal_uInt16 nPage = 0; nPage < mpDoc->GetSdPageCount(PK_STANDARD); nPage++ )
+    for( sal_uInt16 nPage = 0; nPage < pDoc->GetSdPageCount(PK_STANDARD); nPage++ )
     {
-        if(mpDoc->GetSdPage(nPage,PK_STANDARD)->IsSelected())
+        if (pDoc->GetSdPage(nPage,PK_STANDARD)->IsSelected())
         {
             nSelectedPage = nPage;
             break;
         }
     }
     OUString aLayoutName(mpMasterSlide->GetSelectEntry());
-    mpDoc->SetMasterPage(nSelectedPage, aLayoutName, mpDoc, false, false);
+    pDoc->SetMasterPage(nSelectedPage, aLayoutName, pDoc, false, false);
 }
 
 IMPL_LINK_NOARG_TYPED(SlideBackground, DspBackground, Button*, void)
commit bcab5bb03e2944eeb96fb0948c61e175929d07a2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 6 17:02:40 2016 +0100

    coverity#1359235 Resource leak
    
    Change-Id: I3f307211c70384b55b62314a7aa302ffcdfc7398

diff --git a/desktop/unx/source/pagein.c b/desktop/unx/source/pagein.c
index 181637f..56baffa 100644
--- a/desktop/unx/source/pagein.c
+++ b/desktop/unx/source/pagein.c
@@ -46,27 +46,25 @@ static void do_pagein (const char * filename)
 
 int isRotational(char const * path)
 {
+    int ret = 1;
 #ifdef LINUX
     FILE * fp = NULL;
     char fullpath[4096];
     struct stat out;
     int major, minor;
     char type;
-    if(stat( path , &out ) == -1)
-        return 1;
+    if (stat(path , &out) == -1)
+        return ret;
     major = major(out.st_dev);
     minor = 0; /* minor(out.st_dev); only the device itself has a queue */
     sprintf(fullpath,"/sys/dev/block/%d:%d/queue/rotational",major,minor);
-    if ((fp = fopen (fullpath, "r")))
-    {
-        if (fgets(&type, 1, fp))
-        {
-            fclose(fp);
-            return type == '1';
-        }
-    }
+    if ((fp = fopen(fullpath, "r")) == NULL)
+        return ret;
+    if (fgets(&type, 1, fp))
+        ret = type == '1';
+    fclose(fp);
 #endif
-    return 1;
+    return ret;
 }
 
 void pagein_execute(char const * path, char const * file)
commit 9a7da369f73f3306ddd6ed050df3fcdc959742e2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 6 16:57:21 2016 +0100

    coverity#1359236 Uninitialized scalar field
    
    Change-Id: I504b84ad39a8519f495676b7821e3079ac74aaf0

diff --git a/vcl/source/gdi/mapmod.cxx b/vcl/source/gdi/mapmod.cxx
index 0a4a107..70b2065 100644
--- a/vcl/source/gdi/mapmod.cxx
+++ b/vcl/source/gdi/mapmod.cxx
@@ -57,7 +57,8 @@ MapMode::ImplMapMode::ImplMapMode( const ImplMapMode& rImplMapMode ) :
     meUnit( rImplMapMode.meUnit ),
     maOrigin( rImplMapMode.maOrigin ),
     maScaleX( rImplMapMode.maScaleX ),
-    maScaleY( rImplMapMode.maScaleY )
+    maScaleY( rImplMapMode.maScaleY ),
+    mbSimple( rImplMapMode.mbSimple )
 {
 }
 


More information about the Libreoffice-commits mailing list