Bug Summary

File:home/maarten/src/libreoffice/core/svx/source/engine3d/view3d1.cxx
Warning:line 83, column 13
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 view3d1.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 -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 SVXCORE_DLLIMPLEMENTATION -D SYSTEM_LIBXML -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/epoxy/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/pdfium -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/pdfium/public -D COMPONENT_BUILD -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/svx/inc -I /home/maarten/src/libreoffice/core/svx/source/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/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/svx/sdi -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/svx/source/engine3d/view3d1.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
21#include <svx/svdpool.hxx>
22#include <svx/svdmodel.hxx>
23#include <svx/svxids.hrc>
24#include <svx/strings.hrc>
25#include <svx/dialmgr.hxx>
26#include <svx/lathe3d.hxx>
27#include <svx/scene3d.hxx>
28#include <svx/sphere3d.hxx>
29#include <extrud3d.hxx>
30#include <svx/view3d.hxx>
31#include <svx/cube3d.hxx>
32#include <svx/xlineit0.hxx>
33#include <com/sun/star/drawing/LineStyle.hpp>
34
35void E3dView::ConvertMarkedToPolyObj()
36{
37 SdrObject* pNewObj = nullptr;
38
39 if (GetMarkedObjectCount() == 1)
40 {
41 SdrObject* pObj = GetMarkedObjectByIndex(0);
42
43 if (pObj)
44 {
45 auto pScene = dynamic_cast< const E3dScene* >(pObj);
46 if (pScene)
47 {
48 pNewObj = pScene->ConvertToPolyObj(false/*bBezier*/, false/*bLineToArea*/).release();
49 if (pNewObj)
50 {
51 BegUndo(SvxResId(RID_SVX_3D_UNDO_EXTRUDEreinterpret_cast<char const *>("RID_SVX_3D_UNDO_EXTRUDE"
"\004" u8"Create extrusion object")
));
52 ReplaceObjectAtView(pObj, *GetSdrPageView(), pNewObj);
53 EndUndo();
54 }
55 }
56 }
57 }
58
59 if (!pNewObj)
60 {
61 SdrView::ConvertMarkedToPolyObj();
62 }
63}
64
65static void Imp_E3dView_InorderRun3DObjects(const SdrObject* pObj, sal_uInt32& rMask)
66{
67 if(dynamic_cast< const E3dLatheObj* >(pObj) != nullptr)
6
Assuming pointer value is null
7
Taking false branch
68 {
69 rMask |= 0x0001;
70 }
71 else if(dynamic_cast< const E3dExtrudeObj* >(pObj) != nullptr)
8
Taking false branch
72 {
73 rMask |= 0x0002;
74 }
75 else if(dynamic_cast< const E3dSphereObj* >(pObj) != nullptr)
9
Taking false branch
76 {
77 rMask |= 0x0004;
78 }
79 else if(dynamic_cast< const E3dCubeObj* >(pObj) != nullptr)
10
Taking false branch
80 {
81 rMask |= 0x0008;
82 }
83 else if(pObj->IsGroupObject())
11
Called C++ object pointer is null
84 {
85 SdrObjList* pList = pObj->GetSubList();
86 for(size_t a = 0; a < pList->GetObjCount(); ++a)
87 Imp_E3dView_InorderRun3DObjects(pList->GetObj(a), rMask);
88 }
89}
90
91SfxItemSet E3dView::Get3DAttributes() const
92{
93 // Creating itemset with corresponding field
94 SfxItemSet aSet(
95 mpModel->GetItemPool(),
96 svl::Items<SDRATTR_START, SDRATTR_END,
97 SID_ATTR_3D_INTERN( 10000 + 422 ), SID_ATTR_3D_INTERN( 10000 + 422 )>{});
98
99 sal_uInt32 nSelectedItems(0);
100
101 // get attributes from all selected objects
102 MergeAttrFromMarked(aSet, false);
103
104 // calc flags for SID_ATTR_3D_INTERN
105 const SdrMarkList& rMarkList = GetMarkedObjectList();
106 const size_t nMarkCnt(rMarkList.GetMarkCount());
107
108 for(size_t a = 0; a < nMarkCnt; ++a)
109 {
110 SdrObject* pObj = GetMarkedObjectByIndex(a);
111 Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
112 }
113
114 // Set SID_ATTR_3D_INTERN on the status of the selected objects
115 aSet.Put(SfxUInt32Item(SID_ATTR_3D_INTERN( 10000 + 422 ), nSelectedItems));
116
117 // maintain default values
118 if(!nSelectedItems)
119 {
120 // Get defaults and apply
121 SfxItemSet aDefaultSet(mpModel->GetItemPool(), svl::Items<SDRATTR_3D_FIRST, SDRATTR_3D_LAST>{});
122 GetAttributes(aDefaultSet);
123 aSet.Put(aDefaultSet);
124
125 // ... but no lines for 3D
126 aSet.Put(XLineStyleItem (css::drawing::LineStyle_NONE));
127
128 // new defaults for distance and focal length
129 aSet.Put(makeSvx3DDistanceItem(100));
130 aSet.Put(makeSvx3DFocalLengthItem(10000));
131 }
132
133 // return ItemSet
134 return aSet;
135}
136
137void E3dView::Set3DAttributes( const SfxItemSet& rAttr)
138{
139 sal_uInt32 nSelectedItems(0);
140
141 // #i94832# removed usage of E3DModifySceneSnapRectUpdater here.
142 // They are not needed here, they are already handled in SetAttrToMarked
143
144 // set at selected objects
145 SetAttrToMarked(rAttr, false/*bReplaceAll*/);
146
147 // old run
148 const SdrMarkList& rMarkList = GetMarkedObjectList();
149 const size_t nMarkCnt(rMarkList.GetMarkCount());
150
151 for(size_t a = 0; a < nMarkCnt; ++a)
1
Assuming 'a' is < 'nMarkCnt'
2
Loop condition is true. Entering loop body
152 {
153 SdrObject* pObj = GetMarkedObjectByIndex(a);
3
'pObj' initialized here
154 Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
4
Passing value via 1st parameter 'pObj'
5
Calling 'Imp_E3dView_InorderRun3DObjects'
155 }
156
157 // Maintain default values
158 if(!nSelectedItems)
159 {
160 // Set defaults
161 SfxItemSet aDefaultSet(mpModel->GetItemPool(), svl::Items<SDRATTR_3D_FIRST, SDRATTR_3D_LAST>{});
162 aDefaultSet.Put(rAttr);
163 SetAttributes(aDefaultSet);
164 }
165}
166
167double E3dView::GetDefaultCamPosZ()
168{
169 return static_cast<double>(mpModel->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_DISTANCE).GetValue());
170}
171
172double E3dView::GetDefaultCamFocal()
173{
174 return static_cast<double>(mpModel->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_FOCAL_LENGTH).GetValue());
175}
176
177/* vim:set shiftwidth=4 softtabstop=4 expandtab: */