Bug Summary

File:ucbhelper/source/provider/registerucb.cxx
Location:line 90, column 29
Description:Called C++ object pointer is null

Annotated Source Code

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 <ucbhelper/registerucb.hxx>
21#include <com/sun/star/beans/XPropertySet.hpp>
22#include <com/sun/star/lang/XMultiServiceFactory.hpp>
23#include <com/sun/star/ucb/XContentProviderManager.hpp>
24#include <com/sun/star/ucb/XParameterizedContentProvider.hpp>
25#include <com/sun/star/ucb/ContentProviderProxyFactory.hpp>
26#include <com/sun/star/ucb/XContentProviderFactory.hpp>
27#include <com/sun/star/uno/XComponentContext.hpp>
28#include <com/sun/star/uno/RuntimeException.hpp>
29
30#include "osl/diagnose.h"
31
32using namespace com::sun::star;
33
34namespace ucbhelper {
35
36//============================================================================
37//
38// registerAtUcb
39//
40//============================================================================
41
42bool
43registerAtUcb(
44 uno::Reference< ucb::XContentProviderManager > const & rManager,
45 uno::Reference< lang::XMultiServiceFactory > const & rServiceFactory,
46 rtl::OUString const & rName,
47 rtl::OUString const & rArguments,
48 rtl::OUString const & rTemplate,
49 ContentProviderRegistrationInfo * pInfo)
50 throw (uno::RuntimeException)
51{
52 OSL_ENSURE(rServiceFactory.is(),do { if (true && (!(rServiceFactory.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/registerucb.cxx"
":" "53" ": "), "%s", "ucb::registerAtUcb(): No service factory"
); } } while (false)
53 "ucb::registerAtUcb(): No service factory")do { if (true && (!(rServiceFactory.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/registerucb.cxx"
":" "53" ": "), "%s", "ucb::registerAtUcb(): No service factory"
); } } while (false)
;
54
55 bool bNoProxy
56 = rArguments.compareToAscii(RTL_CONSTASCII_STRINGPARAM("{noproxy}")(&("{noproxy}")[0]), ((sal_Int32)(sizeof ("{noproxy}") / sizeof
(("{noproxy}")[0]))-1)
)
57 == 0;
58 rtl::OUString
59 aProviderArguments(bNoProxy ?
1
'?' condition is true
60 rArguments.
61 copy(RTL_CONSTASCII_LENGTH("{noproxy}")((sal_Int32)((sizeof ("{noproxy}") / sizeof (("{noproxy}")[0]
))-1))
) :
62 rArguments);
63
64 // First, try to instantiate proxy for provider:
65 uno::Reference< ucb::XContentProvider > xProvider;
66 if (!bNoProxy)
2
Taking false branch
67 {
68 uno::Reference< ucb::XContentProviderFactory > xProxyFactory;
69 try
70 {
71 uno::Reference< beans::XPropertySet > xFactoryProperties( rServiceFactory, uno::UNO_QUERY_THROW );
72 uno::Reference< uno::XComponentContext > xContext = uno::Reference< uno::XComponentContext >(
73 xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" )(&("DefaultContext")[0]), ((sal_Int32)((sizeof ("DefaultContext"
) / sizeof (("DefaultContext")[0]))-1)), (((rtl_TextEncoding)
11))
) ),
74 uno::UNO_QUERY );
75 xProxyFactory
76 = uno::Reference< ucb::XContentProviderFactory >(
77 ucb::ContentProviderProxyFactory::create( xContext ) );
78 }
79 catch (uno::Exception const &) {}
80 OSL_ENSURE(xProxyFactory.is(), "No ContentProviderProxyFactory")do { if (true && (!(xProxyFactory.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/registerucb.cxx"
":" "80" ": "), "%s", "No ContentProviderProxyFactory"); } }
while (false)
;
81 if (xProxyFactory.is())
82 xProvider = xProxyFactory->createContentProvider(rName);
83 }
84
85 // Then, try to instantiate provider directly:
86 if (!xProvider.is())
3
Taking true branch
87 try
88 {
89 xProvider = uno::Reference< ucb::XContentProvider >(
90 rServiceFactory->createInstance(rName),
4
Called C++ object pointer is null
91 uno::UNO_QUERY);
92 }
93 catch (uno::RuntimeException const &) { throw; }
94 catch (uno::Exception const &) {}
95
96 uno::Reference< ucb::XContentProvider >
97 xOriginalProvider(xProvider);
98 uno::Reference< ucb::XParameterizedContentProvider >
99 xParameterized(xProvider, uno::UNO_QUERY);
100 if (xParameterized.is())
101 {
102 uno::Reference< ucb::XContentProvider > xInstance;
103 try
104 {
105 xInstance = xParameterized->registerInstance(rTemplate,
106 aProviderArguments,
107 true);
108 //@@@ if this call replaces an old instance, the commit-or-
109 // rollback code below will not work
110 }
111 catch (lang::IllegalArgumentException const &) {}
112
113 if (xInstance.is())
114 xProvider = xInstance;
115 }
116
117 bool bSuccess = false;
118 if (rManager.is() && xProvider.is())
119 try
120 {
121 rManager->registerContentProvider(xProvider, rTemplate, true);
122 bSuccess = true;
123 }
124 catch (ucb::DuplicateProviderException const &)
125 {
126 if (xParameterized.is())
127 try
128 {
129 xParameterized->deregisterInstance(rTemplate,
130 aProviderArguments);
131 }
132 catch (lang::IllegalArgumentException const &) {}
133 }
134 catch (...)
135 {
136 if (xParameterized.is())
137 try
138 {
139 xParameterized->deregisterInstance(rTemplate,
140 aProviderArguments);
141 }
142 catch (lang::IllegalArgumentException const &) {}
143 catch (uno::RuntimeException const &) {}
144 throw;
145 }
146
147 if (bSuccess && pInfo)
148 {
149 pInfo->m_xProvider = xOriginalProvider;
150 pInfo->m_aArguments = aProviderArguments;
151 pInfo->m_aTemplate = rTemplate;
152 }
153 return bSuccess;
154}
155
156}
157
158/* vim:set shiftwidth=4 softtabstop=4 expandtab: */