File: | bridges/source/cpp_uno/shared/types.cxx |
Location: | line 101, column 17 |
Description: | Access to field 'eTypeClass' results in a dereference of a null pointer (loaded from variable 't') |
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 "bridges/cpp_uno/shared/types.hxx" | |||||
22 | #define INCLUDED_BRIDGES_CPP_UNO_SHARED_VTABLES_HXX | |||||
23 | ||||||
24 | #include "typelib/typeclass.h" | |||||
25 | #include "typelib/typedescription.h" | |||||
26 | ||||||
27 | namespace bridges { namespace cpp_uno { namespace shared { | |||||
28 | ||||||
29 | bool isSimpleType(typelib_TypeClass typeClass) { | |||||
30 | return typeClass <= typelib_TypeClass_DOUBLE | |||||
31 | || typeClass == typelib_TypeClass_ENUM; | |||||
32 | } | |||||
33 | ||||||
34 | bool isSimpleType(typelib_TypeDescriptionReference const * type) { | |||||
35 | return isSimpleType(type->eTypeClass); | |||||
36 | } | |||||
37 | ||||||
38 | bool isSimpleType(typelib_TypeDescription const * type) { | |||||
39 | return isSimpleType(type->eTypeClass); | |||||
40 | } | |||||
41 | ||||||
42 | bool relatesToInterfaceType(typelib_TypeDescription const * type) { | |||||
43 | switch (type->eTypeClass) { | |||||
| ||||||
44 | case typelib_TypeClass_ANY: | |||||
45 | case typelib_TypeClass_INTERFACE: | |||||
46 | return true; | |||||
47 | ||||||
48 | case typelib_TypeClass_STRUCT: | |||||
49 | case typelib_TypeClass_EXCEPTION: | |||||
50 | { | |||||
51 | typelib_CompoundTypeDescription const * p | |||||
52 | = reinterpret_cast< typelib_CompoundTypeDescription const * >( | |||||
53 | type); | |||||
54 | for (sal_Int32 i = 0; i < p->nMembers; ++i) { | |||||
55 | switch (p->ppTypeRefs[i]->eTypeClass) { | |||||
56 | case typelib_TypeClass_ANY: | |||||
57 | case typelib_TypeClass_INTERFACE: | |||||
58 | return true; | |||||
59 | ||||||
60 | case typelib_TypeClass_STRUCT: | |||||
61 | case typelib_TypeClass_EXCEPTION: | |||||
62 | case typelib_TypeClass_SEQUENCE: | |||||
63 | { | |||||
64 | typelib_TypeDescription * t = 0; | |||||
65 | TYPELIB_DANGER_GET(&t, p->ppTypeRefs[i]){ typelib_TypeDescriptionReference * pMacroTypeRef = (p->ppTypeRefs [i]); typelib_TypeDescription ** ppMacroTypeDescr = (&t); if (((pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) { typelib_typedescriptionreference_getDescription( ppMacroTypeDescr , pMacroTypeRef ); } else if (!pMacroTypeRef->pType || !pMacroTypeRef ->pType->pWeakRef) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); if (*ppMacroTypeDescr) typelib_typedescription_release ( *ppMacroTypeDescr ); } else { *ppMacroTypeDescr = pMacroTypeRef ->pType; } }; | |||||
66 | bool b = relatesToInterfaceType(t); | |||||
67 | TYPELIB_DANGER_RELEASE(t){ if ((((t)->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || ((t)->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) typelib_typedescription_release( t ); }; | |||||
68 | if (b) { | |||||
69 | return true; | |||||
70 | } | |||||
71 | } | |||||
72 | break; | |||||
73 | ||||||
74 | default: | |||||
75 | break; | |||||
76 | } | |||||
77 | } | |||||
78 | if (p->pBaseTypeDescription != 0) { | |||||
79 | return relatesToInterfaceType(&p->pBaseTypeDescription->aBase); | |||||
80 | } | |||||
81 | } | |||||
82 | break; | |||||
83 | ||||||
84 | case typelib_TypeClass_SEQUENCE: | |||||
85 | switch (reinterpret_cast< typelib_IndirectTypeDescription const * >( | |||||
86 | type)->pType->eTypeClass) { | |||||
87 | case typelib_TypeClass_ANY: | |||||
88 | case typelib_TypeClass_INTERFACE: | |||||
89 | return true; | |||||
90 | ||||||
91 | case typelib_TypeClass_STRUCT: | |||||
92 | case typelib_TypeClass_EXCEPTION: | |||||
93 | case typelib_TypeClass_SEQUENCE: | |||||
94 | { | |||||
95 | typelib_TypeDescription * t = 0; | |||||
96 | TYPELIB_DANGER_GET({ typelib_TypeDescriptionReference * pMacroTypeRef = (reinterpret_cast < typelib_IndirectTypeDescription const * >( type)-> pType); typelib_TypeDescription ** ppMacroTypeDescr = (&t ); if (((pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) { typelib_typedescriptionreference_getDescription( ppMacroTypeDescr , pMacroTypeRef ); } else if (!pMacroTypeRef->pType || !pMacroTypeRef ->pType->pWeakRef) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); if (*ppMacroTypeDescr) typelib_typedescription_release ( *ppMacroTypeDescr ); } else { *ppMacroTypeDescr = pMacroTypeRef ->pType; } } | |||||
97 | &t,{ typelib_TypeDescriptionReference * pMacroTypeRef = (reinterpret_cast < typelib_IndirectTypeDescription const * >( type)-> pType); typelib_TypeDescription ** ppMacroTypeDescr = (&t ); if (((pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) { typelib_typedescriptionreference_getDescription( ppMacroTypeDescr , pMacroTypeRef ); } else if (!pMacroTypeRef->pType || !pMacroTypeRef ->pType->pWeakRef) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); if (*ppMacroTypeDescr) typelib_typedescription_release ( *ppMacroTypeDescr ); } else { *ppMacroTypeDescr = pMacroTypeRef ->pType; } } | |||||
98 | reinterpret_cast< typelib_IndirectTypeDescription const * >({ typelib_TypeDescriptionReference * pMacroTypeRef = (reinterpret_cast < typelib_IndirectTypeDescription const * >( type)-> pType); typelib_TypeDescription ** ppMacroTypeDescr = (&t ); if (((pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) { typelib_typedescriptionreference_getDescription( ppMacroTypeDescr , pMacroTypeRef ); } else if (!pMacroTypeRef->pType || !pMacroTypeRef ->pType->pWeakRef) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); if (*ppMacroTypeDescr) typelib_typedescription_release ( *ppMacroTypeDescr ); } else { *ppMacroTypeDescr = pMacroTypeRef ->pType; } } | |||||
99 | type)->pType){ typelib_TypeDescriptionReference * pMacroTypeRef = (reinterpret_cast < typelib_IndirectTypeDescription const * >( type)-> pType); typelib_TypeDescription ** ppMacroTypeDescr = (&t ); if (((pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) { typelib_typedescriptionreference_getDescription( ppMacroTypeDescr , pMacroTypeRef ); } else if (!pMacroTypeRef->pType || !pMacroTypeRef ->pType->pWeakRef) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); if (*ppMacroTypeDescr) typelib_typedescription_release ( *ppMacroTypeDescr ); } else { *ppMacroTypeDescr = pMacroTypeRef ->pType; } }; | |||||
100 | bool b = relatesToInterfaceType(t); | |||||
101 | TYPELIB_DANGER_RELEASE(t){ if ((((t)->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || ((t)->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) typelib_typedescription_release( t ); }; | |||||
| ||||||
102 | return b; | |||||
103 | } | |||||
104 | ||||||
105 | default: | |||||
106 | break; | |||||
107 | } | |||||
108 | break; | |||||
109 | ||||||
110 | default: | |||||
111 | break; | |||||
112 | } | |||||
113 | return false; | |||||
114 | } | |||||
115 | ||||||
116 | } } } | |||||
117 | ||||||
118 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |