clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name uiobject.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 /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/glm -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/libmount -isystem /usr/include/blkid -isystem /usr/include/cairo -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/pixman-1 -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/libxml2 -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/dbus-1.0 -isystem /usr/lib64/dbus-1.0/include -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -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 VCL_DLLIMPLEMENTATION -D DLLIMPLEMENTATION_UITEST -D CUI_DLL_NAME="libcuilo.so" -D DESKTOP_DETECTOR_DLL_NAME="libdesktop_detectorlo.so" -D TK_DLL_NAME="libtklo.so" -D SYSTEM_ZLIB -D GLM_FORCE_CTOR_INIT -D SK_USER_CONFIG_HEADER=</home/maarten/src/libreoffice/core/config_host/config_skia.h> -D SKIA_DLL -D ENABLE_CUPS -D HAVE_VALGRIND_HEADERS -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/skia/include/core -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia/include/effects -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia/include/gpu -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia/include/config -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia/include/ports -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia/include/third_party/vulkan -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia/tools/gpu -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia -I /home/maarten/src/libreoffice/core/external/skia/inc/ -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/mdds/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/lcms2/include -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/workdir/UnpackedTarball/harfbuzz/src -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/graphite/include -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -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/libpng -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/libjpeg-turbo -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/vcl/inc -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/CustomTarget/officecfg/registry -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libxml2 -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/vcl/source/treelist/uiobject.cxx
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | #include <memory> |
11 | #include <vcl/toolkit/svlbitm.hxx> |
12 | #include <vcl/uitest/uiobject.hxx> |
13 | #include <vcl/toolkit/treelistbox.hxx> |
14 | #include <vcl/toolkit/treelistentry.hxx> |
15 | |
16 | TreeListUIObject::TreeListUIObject(const VclPtr<SvTreeListBox>& xTreeList): |
17 | WindowUIObject(xTreeList), |
| 4 | | Calling implicit destructor for 'VclPtr<vcl::Window>' | |
|
| |
| 12 | | Returning from '~Reference' | |
|
| 13 | | Returning from destructor for 'VclPtr<vcl::Window>' | |
|
18 | mxTreeList(xTreeList) |
| 14 | | Calling implicit copy constructor for 'VclPtr<SvTreeListBox>' | |
|
| 15 | | Calling copy constructor for 'Reference<SvTreeListBox>' | |
|
19 | { |
20 | } |
21 | |
22 | namespace { |
23 | |
24 | bool isCheckBoxList(const VclPtr<SvTreeListBox>& xTreeList) |
25 | { |
26 | return (xTreeList->GetTreeFlags() & SvTreeFlags::CHKBTN) == SvTreeFlags::CHKBTN; |
27 | } |
28 | |
29 | } |
30 | |
31 | StringMap TreeListUIObject::get_state() |
32 | { |
33 | StringMap aMap = WindowUIObject::get_state(); |
34 | |
35 | aMap["SelectionCount"] = OUString::number(mxTreeList->GetSelectionCount()); |
36 | aMap["VisibleCount"] = OUString::number(mxTreeList->GetVisibleCount()); |
37 | aMap["Children"] = OUString::number(mxTreeList->GetChildCount(nullptr)); |
38 | aMap["LevelChildren"] = OUString::number(mxTreeList->GetLevelChildCount(nullptr)); |
39 | aMap["CheckBoxList"] = OUString::boolean(isCheckBoxList(mxTreeList)); |
40 | SvTreeListEntry* pEntry = mxTreeList->FirstSelected(); |
41 | aMap["SelectEntryText"] = pEntry ? mxTreeList->GetEntryText(pEntry) : OUString(); |
42 | |
43 | return aMap; |
44 | } |
45 | |
46 | void TreeListUIObject::execute(const OUString& rAction, |
47 | const StringMap& rParameters) |
48 | { |
49 | if (rAction.isEmpty()) |
50 | { |
51 | } |
52 | else |
53 | WindowUIObject::execute(rAction, rParameters); |
54 | } |
55 | |
56 | std::unique_ptr<UIObject> TreeListUIObject::get_child(const OUString& rID) |
57 | { |
58 | sal_Int32 nID = rID.toInt32(); |
59 | if (nID >= 0) |
60 | { |
61 | SvTreeListEntry* pEntry = mxTreeList->GetEntry(nullptr, nID); |
62 | if (!pEntry) |
63 | return nullptr; |
64 | |
65 | return std::unique_ptr<UIObject>(new TreeListEntryUIObject(mxTreeList, pEntry)); |
66 | } |
67 | |
68 | return nullptr; |
69 | } |
70 | |
71 | std::set<OUString> TreeListUIObject::get_children() const |
72 | { |
73 | std::set<OUString> aChildren; |
74 | |
75 | size_t nChildren = mxTreeList->GetLevelChildCount(nullptr); |
76 | for (size_t i = 0; i < nChildren; ++i) |
77 | { |
78 | aChildren.insert(OUString::number(i)); |
79 | } |
80 | |
81 | return aChildren; |
82 | } |
83 | |
84 | OUString TreeListUIObject::get_name() const |
85 | { |
86 | return "TreeListUIObject"; |
87 | } |
88 | |
89 | std::unique_ptr<UIObject> TreeListUIObject::create(vcl::Window* pWindow) |
90 | { |
91 | SvTreeListBox* pTreeList = dynamic_cast<SvTreeListBox*>(pWindow); |
92 | assert(pTreeList); |
| 1 | Assuming 'pTreeList' is non-null | |
|
| |
93 | return std::unique_ptr<UIObject>(new TreeListUIObject(pTreeList)); |
| 3 | | Calling constructor for 'TreeListUIObject' | |
|
94 | } |
95 | |
96 | TreeListEntryUIObject::TreeListEntryUIObject(const VclPtr<SvTreeListBox>& xTreeList, SvTreeListEntry* pEntry): |
97 | mxTreeList(xTreeList), |
98 | mpEntry(pEntry) |
99 | { |
100 | } |
101 | |
102 | StringMap TreeListEntryUIObject::get_state() |
103 | { |
104 | StringMap aMap; |
105 | |
106 | aMap["Text"] = mxTreeList->GetEntryText(mpEntry); |
107 | aMap["Children"] = OUString::number(mxTreeList->GetLevelChildCount(mpEntry)); |
108 | aMap["VisibleChildCount"] = OUString::number(mxTreeList->GetVisibleChildCount(mpEntry)); |
109 | aMap["IsSelected"] = OUString::boolean(mxTreeList->IsSelected(mpEntry)); |
110 | |
111 | return aMap; |
112 | } |
113 | |
114 | void TreeListEntryUIObject::execute(const OUString& rAction, const StringMap& ) |
115 | { |
116 | if (rAction == "COLLAPSE") |
117 | { |
118 | mxTreeList->Collapse(mpEntry); |
119 | } |
120 | else if (rAction == "EXPAND") |
121 | { |
122 | mxTreeList->Expand(mpEntry); |
123 | } |
124 | else if (rAction == "SELECT") |
125 | { |
126 | mxTreeList->Select(mpEntry); |
127 | } |
128 | else if (rAction == "DESELECT") |
129 | { |
130 | mxTreeList->Select(mpEntry, false); |
131 | } |
132 | else if (rAction == "CLICK") |
133 | { |
134 | SvLBoxButton* pItem = static_cast<SvLBoxButton*>(mpEntry->GetFirstItem(SvLBoxItemType::Button)); |
135 | if (!pItem) |
136 | return; |
137 | pItem->ClickHdl(mpEntry); |
138 | } |
139 | else if (rAction == "DOUBLECLICK") |
140 | { |
141 | mxTreeList->Select(mpEntry); |
142 | mxTreeList->DoubleClickHdl(); |
143 | } |
144 | } |
145 | |
146 | std::unique_ptr<UIObject> TreeListEntryUIObject::get_child(const OUString& rID) |
147 | { |
148 | sal_Int32 nID = rID.toInt32(); |
149 | if (nID >= 0) |
150 | { |
151 | SvTreeListEntry* pEntry = mxTreeList->GetEntry(mpEntry, nID); |
152 | if (!pEntry) |
153 | return nullptr; |
154 | |
155 | return std::unique_ptr<UIObject>(new TreeListEntryUIObject(mxTreeList, pEntry)); |
156 | } |
157 | |
158 | return nullptr; |
159 | } |
160 | |
161 | std::set<OUString> TreeListEntryUIObject::get_children() const |
162 | { |
163 | std::set<OUString> aChildren; |
164 | |
165 | size_t nChildren = mxTreeList->GetLevelChildCount(mpEntry); |
166 | for (size_t i = 0; i < nChildren; ++i) |
167 | { |
168 | aChildren.insert(OUString::number(i)); |
169 | } |
170 | |
171 | return aChildren; |
172 | } |
173 | |
174 | OUString TreeListEntryUIObject::get_type() const |
175 | { |
176 | return "TreeListEntry"; |
177 | } |
178 | |
179 | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | #ifndef INCLUDED_RTL_REF_HXX |
21 | #define INCLUDED_RTL_REF_HXX |
22 | |
23 | #include "sal/config.h" |
24 | |
25 | #include <cassert> |
26 | #include <cstddef> |
27 | #include <functional> |
28 | #ifdef LIBO_INTERNAL_ONLY |
29 | #include <type_traits> |
30 | #endif |
31 | |
32 | #include "sal/types.h" |
33 | |
34 | namespace rtl |
35 | { |
36 | |
37 | |
38 | |
39 | template <class reference_type> |
40 | class Reference |
41 | { |
42 | |
43 | |
44 | reference_type * m_pBody; |
45 | |
46 | |
47 | public: |
48 | |
49 | |
50 | Reference() |
51 | : m_pBody (NULL) |
52 | {} |
53 | |
54 | |
55 | |
56 | |
57 | Reference (reference_type * pBody, __sal_NoAcquire) |
58 | : m_pBody (pBody) |
59 | { |
60 | } |
61 | |
62 | |
63 | |
64 | Reference (reference_type * pBody) |
65 | : m_pBody (pBody) |
66 | { |
67 | if (m_pBody) |
68 | m_pBody->acquire(); |
69 | } |
70 | |
71 | |
72 | |
73 | Reference (const Reference<reference_type> & handle) |
74 | : m_pBody (handle.m_pBody) |
75 | { |
76 | if (m_pBody) |
| |
77 | m_pBody->acquire(); |
| 17 | | Use of memory after it is freed |
|
78 | } |
79 | |
80 | #ifdef LIBO_INTERNAL_ONLY |
81 | |
82 | |
83 | Reference (Reference<reference_type> && handle) noexcept |
84 | : m_pBody (handle.m_pBody) |
85 | { |
86 | handle.m_pBody = nullptr; |
87 | } |
88 | #endif |
89 | |
90 | #if defined LIBO_INTERNAL_ONLY |
91 | |
92 | |
93 | |
94 | |
95 | |
96 | |
97 | template< class derived_type > |
98 | inline Reference( |
99 | const Reference< derived_type > & rRef, |
100 | std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 ) |
101 | : m_pBody (rRef.get()) |
102 | { |
103 | if (m_pBody) |
104 | m_pBody->acquire(); |
105 | } |
106 | #endif |
107 | |
108 | |
109 | |
110 | ~Reference() COVERITY_NOEXCEPT_FALSE |
111 | { |
112 | if (m_pBody) |
| |
113 | m_pBody->release(); |
| 7 | | Calling 'VclReferenceBase::release' | |
|
| 11 | | Returning; memory was released | |
|
114 | } |
115 | |
116 | |
117 | |
118 | |
119 | Reference<reference_type> & |
120 | SAL_CALL set (reference_type * pBody) |
121 | { |
122 | if (pBody) |
123 | pBody->acquire(); |
124 | reference_type * const pOld = m_pBody; |
125 | m_pBody = pBody; |
126 | if (pOld) |
127 | pOld->release(); |
128 | return *this; |
129 | } |
130 | |
131 | |
132 | |
133 | |
134 | |
135 | Reference<reference_type> & |
136 | SAL_CALL operator= (const Reference<reference_type> & handle) |
137 | { |
138 | return set( handle.m_pBody ); |
139 | } |
140 | |
141 | #ifdef LIBO_INTERNAL_ONLY |
142 | |
143 | |
144 | |
145 | |
146 | |
147 | Reference<reference_type> & |
148 | operator= (Reference<reference_type> && handle) |
149 | { |
150 | |
151 | if (m_pBody) |
152 | m_pBody->release(); |
153 | m_pBody = handle.m_pBody; |
154 | handle.m_pBody = nullptr; |
155 | return *this; |
156 | } |
157 | #endif |
158 | |
159 | |
160 | |
161 | Reference<reference_type> & |
162 | SAL_CALL operator= (reference_type * pBody) |
163 | { |
164 | return set( pBody ); |
165 | } |
166 | |
167 | |
168 | |
169 | |
170 | |
171 | |
172 | |
173 | |
174 | Reference<reference_type> & SAL_CALL clear() |
175 | { |
176 | if (m_pBody) |
177 | { |
178 | reference_type * const pOld = m_pBody; |
179 | m_pBody = NULL; |
180 | pOld->release(); |
181 | } |
182 | return *this; |
183 | } |
184 | |
185 | |
186 | |
187 | |
188 | |
189 | |
190 | reference_type * SAL_CALL get() const |
191 | { |
192 | return m_pBody; |
193 | } |
194 | |
195 | |
196 | |
197 | |
198 | reference_type * SAL_CALL operator->() const |
199 | { |
200 | assert(m_pBody != NULL); |
201 | return m_pBody; |
202 | } |
203 | |
204 | |
205 | |
206 | |
207 | reference_type & SAL_CALL operator*() const |
208 | { |
209 | assert(m_pBody != NULL); |
210 | return *m_pBody; |
211 | } |
212 | |
213 | |
214 | |
215 | |
216 | bool SAL_CALL is() const |
217 | { |
218 | return (m_pBody != NULL); |
219 | } |
220 | |
221 | #if defined LIBO_INTERNAL_ONLY |
222 | |
223 | |
224 | explicit operator bool() const |
225 | { |
226 | return is(); |
227 | } |
228 | #endif |
229 | |
230 | |
231 | |
232 | bool SAL_CALL operator== (const reference_type * pBody) const |
233 | { |
234 | return (m_pBody == pBody); |
235 | } |
236 | |
237 | |
238 | |
239 | |
240 | bool |
241 | SAL_CALL operator== (const Reference<reference_type> & handle) const |
242 | { |
243 | return (m_pBody == handle.m_pBody); |
244 | } |
245 | |
246 | |
247 | |
248 | |
249 | bool |
250 | SAL_CALL operator!= (const Reference<reference_type> & handle) const |
251 | { |
252 | return (m_pBody != handle.m_pBody); |
253 | } |
254 | |
255 | |
256 | |
257 | |
258 | bool |
259 | SAL_CALL operator< (const Reference<reference_type> & handle) const |
260 | { |
261 | return (m_pBody < handle.m_pBody); |
262 | } |
263 | |
264 | |
265 | |
266 | |
267 | bool |
268 | SAL_CALL operator> (const Reference<reference_type> & handle) const |
269 | { |
270 | return (m_pBody > handle.m_pBody); |
271 | } |
272 | }; |
273 | |
274 | } |
275 | |
276 | #if defined LIBO_INTERNAL_ONLY |
277 | namespace std |
278 | { |
279 | |
280 | |
281 | |
282 | |
283 | |
284 | |
285 | |
286 | template<typename T> |
287 | struct hash<::rtl::Reference<T>> |
288 | { |
289 | std::size_t operator()(::rtl::Reference<T> const & s) const |
290 | { return std::size_t(s.get()); } |
291 | }; |
292 | |
293 | |
294 | } |
295 | |
296 | #endif |
297 | |
298 | #endif /* ! INCLUDED_RTL_REF_HXX */ |
299 | |
300 | |