Bug Summary

File:stoc/source/registry_tdprovider/tdsingleton.cxx
Location:line 53, column 20
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 <osl/diagnose.h>
21#include "base.hxx"
22
23#include "com/sun/star/uno/RuntimeException.hpp"
24
25using namespace com::sun::star;
26
27namespace stoc_rdbtdp
28{
29
30void SingletonTypeDescriptionImpl::init() {
31 {
32 MutexGuard guard(getMutex());
33 if (_xInterfaceTD.is() || _xServiceTD.is()) {
2
Taking false branch
34 return;
35 }
36 }
37 Reference< XTypeDescription > base;
38 try {
39 base = Reference< XTypeDescription >(
40 _xTDMgr->getByHierarchicalName(_aBaseName), UNO_QUERY_THROW);
41 } catch (NoSuchElementException const & e) {
42 throw RuntimeException(
43 (OUString(
44 RTL_CONSTASCII_USTRINGPARAM((&("com.sun.star.container.NoSuchElementException: ")[0])
, ((sal_Int32)((sizeof ("com.sun.star.container.NoSuchElementException: "
) / sizeof (("com.sun.star.container.NoSuchElementException: "
)[0]))-1)), (((rtl_TextEncoding) 11))
45 "com.sun.star.container.NoSuchElementException: ")(&("com.sun.star.container.NoSuchElementException: ")[0])
, ((sal_Int32)((sizeof ("com.sun.star.container.NoSuchElementException: "
) / sizeof (("com.sun.star.container.NoSuchElementException: "
)[0]))-1)), (((rtl_TextEncoding) 11))
)
46 + e.Message),
47 static_cast< OWeakObject * >(this));
48 }
49 MutexGuard guard(getMutex());
50 if (!_xInterfaceTD.is() && !_xServiceTD.is()) {
3
Taking true branch
51 if (resolveTypedefs(base)->getTypeClass() == TypeClass_INTERFACE) {
4
Taking false branch
52 _xInterfaceTD = base;
53 } else if (base->getTypeClass() == TypeClass_SERVICE) {
5
Called C++ object pointer is null
54 _xServiceTD = Reference< XServiceTypeDescription >(
55 base, UNO_QUERY_THROW);
56 } else {
57 throw RuntimeException(
58 OUString(
59 RTL_CONSTASCII_USTRINGPARAM((&("Singleton is based on neither interface nor service")
[0]), ((sal_Int32)((sizeof ("Singleton is based on neither interface nor service"
) / sizeof (("Singleton is based on neither interface nor service"
)[0]))-1)), (((rtl_TextEncoding) 11))
60 "Singleton is based on neither interface nor service")(&("Singleton is based on neither interface nor service")
[0]), ((sal_Int32)((sizeof ("Singleton is based on neither interface nor service"
) / sizeof (("Singleton is based on neither interface nor service"
)[0]))-1)), (((rtl_TextEncoding) 11))
),
61 static_cast< OWeakObject * >(this));
62 }
63 }
64 OSL_ASSERT(_xInterfaceTD.is() ^ _xServiceTD.is())do { if (true && (!(_xInterfaceTD.is() ^ _xServiceTD.
is()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), (
"legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/registry_tdprovider/tdsingleton.cxx"
":" "64" ": "), "OSL_ASSERT: %s", "_xInterfaceTD.is() ^ _xServiceTD.is()"
); } } while (false)
;
65}
66
67//__________________________________________________________________________________________________
68// virtual
69SingletonTypeDescriptionImpl::~SingletonTypeDescriptionImpl()
70{
71 g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
72}
73
74// XTypeDescription
75//__________________________________________________________________________________________________
76// virtual
77TypeClass SingletonTypeDescriptionImpl::getTypeClass()
78 throw(::com::sun::star::uno::RuntimeException)
79{
80 return TypeClass_SINGLETON;
81}
82//__________________________________________________________________________________________________
83// virtual
84OUString SingletonTypeDescriptionImpl::getName()
85 throw(::com::sun::star::uno::RuntimeException)
86{
87 return _aName;
88}
89
90// XSingletonTypeDescription
91//__________________________________________________________________________________________________
92// virtual
93Reference< XServiceTypeDescription > SAL_CALL
94SingletonTypeDescriptionImpl::getService()
95 throw(::com::sun::star::uno::RuntimeException)
96{
97 init();
98 return _xServiceTD;
99}
100
101// XSingletonTypeDescription2
102//______________________________________________________________________________
103// virtual
104sal_Bool SAL_CALL
105SingletonTypeDescriptionImpl::isInterfaceBased()
106 throw(::com::sun::star::uno::RuntimeException)
107{
108 init();
109 return _xInterfaceTD.is();
110}
111
112//______________________________________________________________________________
113// virtual
114Reference< XTypeDescription > SAL_CALL
115SingletonTypeDescriptionImpl::getInterface()
116 throw(::com::sun::star::uno::RuntimeException)
117{
118 init();
1
Calling 'init'
119 return _xInterfaceTD;
120}
121
122}
123
124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */