Bug Summary

File:codemaker/source/codemaker/codemaker.cxx
Location:line 125, column 25
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
21#include "sal/config.h"
22
23#include "codemaker/codemaker.hxx"
24
25#include "codemaker/options.hxx"
26#include "codemaker/typemanager.hxx"
27#include "codemaker/unotype.hxx"
28
29#include "osl/diagnose.h"
30#include "registry/reader.hxx"
31#include "registry/types.h"
32#include "rtl/strbuf.h"
33#include "rtl/string.h"
34#include "rtl/string.hxx"
35#include "rtl/ustring.hxx"
36#include "sal/types.h"
37
38#include <vector>
39
40namespace {
41
42void checkNoTypeArguments(std::vector< rtl::OString > const & arguments) {
43 if (!arguments.empty()) {
44 throw CannotDumpException(
45 rtl::OString(RTL_CONSTASCII_STRINGPARAM("Bad type information")(&("Bad type information")[0]), ((sal_Int32)(sizeof ("Bad type information"
) / sizeof (("Bad type information")[0]))-1)
));
46 //TODO
47 }
48}
49
50}
51
52namespace codemaker {
53
54rtl::OString convertString(rtl::OUString const & string) {
55 rtl::OString s;
56 if (!string.convertToString(
57 &s, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)),
58 (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR((sal_uInt32)0x0001)
59 | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR((sal_uInt32)0x0010))))
60 {
61 throw CannotDumpException(
62 rtl::OString(
63 RTL_CONSTASCII_STRINGPARAM((&("Failure converting string from UTF-16 to UTF-8")[0]),
((sal_Int32)(sizeof ("Failure converting string from UTF-16 to UTF-8"
) / sizeof (("Failure converting string from UTF-16 to UTF-8"
)[0]))-1)
64 "Failure converting string from UTF-16 to UTF-8")(&("Failure converting string from UTF-16 to UTF-8")[0]),
((sal_Int32)(sizeof ("Failure converting string from UTF-16 to UTF-8"
) / sizeof (("Failure converting string from UTF-16 to UTF-8"
)[0]))-1)
));
65 }
66 return s;
67}
68
69rtl::OString errorMsg(rtl::OString const & desc, rtl::OString const & type) {
70 rtl::OStringBuffer msg(128);
71 msg.append(desc);
72 msg.append(type);
73 return msg.makeStringAndClear();
74}
75
76codemaker::UnoType::Sort decomposeAndResolve(
77 TypeManager const & manager, rtl::OString const & type,
78 bool resolveTypedefs, bool allowVoid, bool allowExtraEntities,
79 RTTypeClass * typeClass, rtl::OString * name, sal_Int32 * rank,
80 std::vector< rtl::OString > * arguments)
81{
82 OSL_ASSERT(typeClass != 0 && name != 0 && rank != 0 && arguments != 0)do { if (true && (!(typeClass != 0 && name !=
0 && rank != 0 && arguments != 0))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/codemaker/source/codemaker/codemaker.cxx"
":" "82" ": "), "OSL_ASSERT: %s", "typeClass != 0 && name != 0 && rank != 0 && arguments != 0"
); } } while (false)
;
83 *rank = 0;
84 for (rtl::OString t(type);;) {
1
Loop condition is true. Entering loop body
85 sal_Int32 n = 0;
86 *name = codemaker::UnoType::decompose(t, &n, arguments);
87 if (n > SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF) - *rank) {
2
Taking false branch
88 throw CannotDumpException(
89 errorMsg(rtl::OString(
90 RTL_CONSTASCII_STRINGPARAM("Bad type information: ")(&("Bad type information: ")[0]), ((sal_Int32)(sizeof ("Bad type information: "
) / sizeof (("Bad type information: ")[0]))-1)
),
91 type));
92 //TODO
93 }
94 *rank += n;
95 if (n > 0) {
3
Taking false branch
96 allowVoid = false;
97 allowExtraEntities = false;
98 }
99 codemaker::UnoType::Sort sort = codemaker::UnoType::getSort(*name);
100 switch (sort) {
4
Control jumps to 'case SORT_COMPLEX:' at line 114
101 case codemaker::UnoType::SORT_VOID:
102 if (!allowVoid) {
103 throw CannotDumpException(
104 errorMsg(rtl::OString(
105 RTL_CONSTASCII_STRINGPARAM("Bad type information: ")(&("Bad type information: ")[0]), ((sal_Int32)(sizeof ("Bad type information: "
) / sizeof (("Bad type information: ")[0]))-1)
),
106 type));
107 //TODO
108 }
109 default:
110 checkNoTypeArguments(*arguments);
111 *typeClass = RT_TYPE_INVALID;
112 return sort;
113
114 case codemaker::UnoType::SORT_COMPLEX:
115 typereg::Reader reader(manager.getTypeReader(*name));
116 *typeClass = reader.getTypeClass();
117 switch (*typeClass) {
5
Control jumps to 'case RT_TYPE_STRUCT:' at line 123
118 case RT_TYPE_ENUM:
119 case RT_TYPE_INTERFACE:
120 checkNoTypeArguments(*arguments);
121 return sort;
122
123 case RT_TYPE_STRUCT:
124 if (!(allowExtraEntities && arguments->empty())
125 && (arguments->size() > SAL_MAX_UINT16((sal_uInt16) 0xFFFF)
6
Called C++ object pointer is null
126 || (static_cast< sal_uInt16 >(arguments->size())
127 != reader.getReferenceCount())))
128 {
129 throw CannotDumpException(
130 errorMsg(rtl::OString(
131 RTL_CONSTASCII_STRINGPARAM("Bad type information: ")(&("Bad type information: ")[0]), ((sal_Int32)(sizeof ("Bad type information: "
) / sizeof (("Bad type information: ")[0]))-1)
),
132 type));
133 //TODO
134 }
135 return sort;
136
137 case RT_TYPE_MODULE:
138 case RT_TYPE_EXCEPTION:
139 case RT_TYPE_SERVICE:
140 case RT_TYPE_SINGLETON:
141 case RT_TYPE_CONSTANTS:
142 if (!allowExtraEntities) {
143 throw CannotDumpException(
144 errorMsg(rtl::OString(
145 RTL_CONSTASCII_STRINGPARAM("Bad type information: ")(&("Bad type information: ")[0]), ((sal_Int32)(sizeof ("Bad type information: "
) / sizeof (("Bad type information: ")[0]))-1)
),
146 type));
147 //TODO
148 }
149 checkNoTypeArguments(*arguments);
150 //TODO: check reader for consistency
151 return sort;
152
153 case RT_TYPE_TYPEDEF:
154 checkNoTypeArguments(*arguments);
155 if (reader.getSuperTypeCount() == 1
156 && reader.getFieldCount() == 0
157 && reader.getMethodCount() == 0
158 && reader.getReferenceCount() == 0)
159 {
160 if (resolveTypedefs) {
161 t = convertString(reader.getSuperTypeName(0));
162 continue;
163 } else {
164 return sort;
165 }
166 }
167 default:
168 throw CannotDumpException(
169 errorMsg(rtl::OString(
170 RTL_CONSTASCII_STRINGPARAM("Bad type information: ")(&("Bad type information: ")[0]), ((sal_Int32)(sizeof ("Bad type information: "
) / sizeof (("Bad type information: ")[0]))-1)
),
171 type));
172 //TODO
173 }
174 }
175 }
176}
177
178}
179
180/* vim:set shiftwidth=4 softtabstop=4 expandtab: */