Bug Summary

File:home/maarten/src/libreoffice/core/sd/source/ui/func/fulinend.cxx
Warning:line 70, column 9
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name fulinend.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -isystem /usr/include/libxml2 -isystem /usr/include/dbus-1.0 -isystem /usr/lib64/dbus-1.0/include -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D SD_DLLIMPLEMENTATION -D SDUI_DLL_NAME="libsduilo.so" -D SYSTEM_LIBXML -D ENABLE_SDREMOTE -D ENABLE_SDREMOTE_BLUETOOTH -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/common -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/external/bluez_bluetooth/inc -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/sd/inc -I /home/maarten/src/libreoffice/core/sd/source/ui/inc -I /home/maarten/src/libreoffice/core/sd/source/ui/slidesorter/inc -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/sd/sdi -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/oox/generated -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/sd/source/ui/func/fulinend.cxx
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <fulinend.hxx>
21#include <svx/xtable.hxx>
22#include <svx/svxdlg.hxx>
23#include <svx/svdobj.hxx>
24#include <svx/svdopath.hxx>
25#include <vcl/svapp.hxx>
26#include <vcl/weld.hxx>
27
28#include <strings.hrc>
29#include <helpids.h>
30#include <sdresid.hxx>
31#include <drawdoc.hxx>
32#include <View.hxx>
33#include <Window.hxx>
34#include <memory>
35
36namespace sd {
37
38
39FuLineEnd::FuLineEnd(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
40 SdDrawDocument* pDoc, SfxRequest& rReq)
41 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
42{
43}
44
45rtl::Reference<FuPoor> FuLineEnd::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
46{
47 rtl::Reference<FuPoor> xFunc( new FuLineEnd( pViewSh, pWin, pView, pDoc, rReq ) );
48 xFunc->DoExecute(rReq);
49 return xFunc;
50}
51
52void FuLineEnd::DoExecute( SfxRequest& )
53{
54 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
55
56 if( rMarkList.GetMarkCount() != 1 )
1
Assuming the condition is false
2
Taking false branch
57 return;
58
59 const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
3
'pObj' initialized here
60 const SdrObject* pNewObj;
61 SdrObjectUniquePtr pConvPolyObj;
62
63 if( dynamic_cast< const SdrPathObj *>( pObj ) != nullptr )
4
Assuming pointer value is null
5
Taking false branch
64 {
65 pNewObj = pObj;
66 }
67 else
68 {
69 SdrObjTransformInfoRec aInfoRec;
70 pObj->TakeObjInfo( aInfoRec );
6
Called C++ object pointer is null
71
72 if( aInfoRec.bCanConvToPath &&
73 pObj->GetObjInventor() == SdrInventor::Default &&
74 pObj->GetObjIdentifier() != OBJ_GRUP )
75 // bCanConvToPath is sal_True for group objects,
76 // but it crashes on ConvertToPathObj()!
77 {
78 pConvPolyObj = pObj->ConvertToPolyObj( true, false );
79 pNewObj = pConvPolyObj.get();
80
81 if( !pNewObj || dynamic_cast< const SdrPathObj *>( pNewObj ) == nullptr )
82 return; // Cancel, additional security, but it does not help
83 // for group objects
84 }
85 else return; // Cancel
86 }
87
88 const ::basegfx::B2DPolyPolygon aPolyPolygon = static_cast<const SdrPathObj*>(pNewObj)->GetPathPoly();
89
90 // Delete the created poly-object
91 pConvPolyObj.reset();
92
93 XLineEndListRef pLineEndList = mpDoc->GetLineEndList();
94
95 OUString aNewName( SdResId( STR_LINEENDreinterpret_cast<char const *>("STR_LINEEND" "\004" u8"Line Ends"
)
) );
96 OUString aDesc( SdResId( STR_DESC_LINEENDreinterpret_cast<char const *>("STR_DESC_LINEEND" "\004"
u8"Please enter a name for the new arrowhead:")
) );
97 OUString aName;
98
99 long nCount = pLineEndList->Count();
100 long j = 1;
101 bool bDifferent = false;
102
103 while( !bDifferent )
104 {
105 aName = aNewName + " " + OUString::number(j++);
106 bDifferent = true;
107 for( long i = 0; i < nCount && bDifferent; i++ )
108 {
109 if( aName == pLineEndList->GetLineEnd( i )->GetName() )
110 bDifferent = false;
111 }
112 }
113
114 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
115 ScopedVclPtr<AbstractSvxNameDialog> pDlg( pFact->CreateSvxNameDialog( nullptr, aName, aDesc ) );
116
117 pDlg->SetEditHelpId( HID_SD_NAMEDIALOG_LINEEND"SD_HID_SD_NAMEDIALOG_LINEEND" );
118
119 if( pDlg->Execute() != RET_OK )
120 return;
121
122 pDlg->GetName( aName );
123 bDifferent = true;
124
125 for( long i = 0; i < nCount && bDifferent; i++ )
126 {
127 if( aName == pLineEndList->GetLineEnd( i )->GetName() )
128 bDifferent = false;
129 }
130
131 if( bDifferent )
132 {
133 pLineEndList->Insert(std::make_unique<XLineEndEntry>(aPolyPolygon, aName));
134 }
135 else
136 {
137 std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(mpWindow ? mpWindow->GetFrameWeld() : nullptr,
138 VclMessageType::Warning, VclButtonsType::Ok,
139 SdResId(STR_WARN_NAME_DUPLICATEreinterpret_cast<char const *>("STR_WARN_NAME_DUPLICATE"
"\004" u8"The name chosen already exists. \nPlease enter another name."
)
)));
140 xWarn->run();
141 }
142}
143
144void FuLineEnd::Activate()
145{
146}
147
148void FuLineEnd::Deactivate()
149{
150}
151
152} // end of namespace sd
153
154/* vim:set shiftwidth=4 softtabstop=4 expandtab: */