Bug Summary

File:home/maarten/src/libreoffice/core/vcl/source/uipreviewer/previewer.cxx
Warning:line 90, 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 previewer.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 -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_INTERNALS -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -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/UnoApiHeadersTarget/offapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -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/uipreviewer/previewer.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
10#include <com/sun/star/lang/XComponent.hpp>
11#include <com/sun/star/lang/XMultiComponentFactory.hpp>
12#include <com/sun/star/lang/XMultiServiceFactory.hpp>
13#include <com/sun/star/ucb/UniversalContentBroker.hpp>
14#include <comphelper/processfactory.hxx>
15#include <cppuhelper/bootstrap.hxx>
16#include <osl/file.hxx>
17#include <vcl/builder.hxx>
18#include <vcl/toolkit/dialog.hxx>
19#include <vcl/help.hxx>
20#include <vcl/svapp.hxx>
21#include <vcl/vclmain.hxx>
22
23namespace {
24
25class UIPreviewApp : public Application
26{
27public:
28 virtual void Init() override;
29 virtual int Main() override;
30};
31
32}
33
34using namespace com::sun::star;
35
36void UIPreviewApp::Init()
37{
38 uno::Reference<uno::XComponentContext> xContext =
39 cppu::defaultBootstrap_InitialComponentContext();
40 uno::Reference<lang::XMultiComponentFactory> xFactory =
41 xContext->getServiceManager();
42 uno::Reference<lang::XMultiServiceFactory> xSFactory(xFactory, uno::UNO_QUERY_THROW);
43 comphelper::setProcessServiceFactory(xSFactory);
44
45 // Create UCB (for backwards compatibility, in case some code still uses
46 // plain createInstance w/o args directly to obtain an instance):
47 ::ucb::UniversalContentBroker::create(
48 comphelper::getProcessComponentContext() );
49}
50
51int UIPreviewApp::Main()
52{
53 std::vector<OUString> uifiles;
54 for (sal_uInt16 i = 0; i < GetCommandLineParamCount(); ++i)
1
Assuming the condition is false
2
Loop condition is false. Execution continues on line 61
55 {
56 OUString aFileUrl;
57 osl::File::getFileURLFromSystemPath(GetCommandLineParam(i), aFileUrl);
58 uifiles.push_back(aFileUrl);
59 }
60
61 if (uifiles.empty())
3
Assuming the condition is false
4
Taking false branch
62 {
63 fprintf(stderrstderr, "Usage: ui-previewer file.ui\n");
64 return EXIT_FAILURE1;
65 }
66
67 // turn on tooltips
68 Help::EnableQuickHelp();
69
70 int nRet = EXIT_SUCCESS0;
71
72 try
73 {
74 VclPtrInstance<Dialog> pDialog(nullptr, WB_STDDIALOG | WB_SIZEABLE, Dialog::InitFlag::NoParent);
75 {
76 VclBuilder aBuilder(pDialog, OUString(), uifiles[0]);
77 vcl::Window *pRoot = aBuilder.get_widget_root();
5
'pRoot' initialized here
78 Dialog *pRealDialog = dynamic_cast<Dialog*>(pRoot);
79
80 if (!pRealDialog)
6
Assuming 'pRealDialog' is null
7
Taking true branch
81 pRealDialog = pDialog;
82
83 pRealDialog->SetText("LibreOffice ui-previewer");
84 pRealDialog->SetStyle(pDialog->GetStyle()|WB_CLOSEABLE);
85 /*
86 Force a new StateChangedType::InitShow for the edge case where pRoot
87 is not a dialog or contents of a dialog, but instead a visible floating window
88 which may have had initshow already done before it was given children
89 */
90 pRoot->Hide();
8
Called C++ object pointer is null
91 pRoot->Show();
92 pRealDialog->Execute();
93 }
94
95 pDialog.disposeAndClear();
96 }
97 catch (const uno::Exception &e)
98 {
99 fprintf(stderrstderr, "fatal error: %s\n", OUStringToOString(e.Message, osl_getThreadTextEncoding()).getStr());
100 nRet = EXIT_FAILURE1;
101 }
102 catch (const std::exception &e)
103 {
104 fprintf(stderrstderr, "fatal error: %s\n", e.what());
105 nRet = EXIT_FAILURE1;
106 }
107
108 return nRet;
109}
110
111void vclmain::createApplication()
112{
113 static UIPreviewApp aApp;
114}
115
116/* vim:set shiftwidth=4 softtabstop=4 expandtab: */