10000 Merge pull request #4849 from arangodb/bug-fix/internal-issue-#376 · mnemosdev/arangodb@747b9f0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 747b9f0

Browse files
author
Andrey Abramov
authored
Merge pull request arangodb#4849 from arangodb/bug-fix/internal-issue-#376
add nullptr check
2 parents dee95e6 + b193bee commit 747b9f0

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

arangod/VocBase/vocbase.cpp

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,8 +1024,9 @@ std::shared_ptr<arangodb::LogicalCollection> TRI_vocbase_t::lookupCollection(
10241024
#else
10251025
auto dataSource = lookupDataSource(id);
10261026

1027-
return dataSource->category() == LogicalCollection::category()
1028-
? std::static_pointer_cast<LogicalCollection>(dataSource) : nullptr;
1027+
return dataSource && dataSource->category() == LogicalCollection::category()
1028+
? std::static_pointer_cast<LogicalCollection>(dataSource)
1029+
: nullptr;
10291030
#endif
10301031
}
10311032

@@ -1040,8 +1041,9 @@ std::shared_ptr<arangodb::LogicalCollection> TRI_vocbase_t::lookupCollection(
10401041
#else
10411042
auto dataSource = lookupDataSource(nameOrId);
10421043

1043-
return dataSource->category() == LogicalCollection::category()
1044-
? std::static_pointer_cast<LogicalCollection>(dataSource) : nullptr;
1044+
return dataSource && dataSource->category() == LogicalCollection::category()
1045+
? std::static_pointer_cast<LogicalCollection>(dataSource)
1046+
: nullptr;
10451047
#endif
10461048
}
10471049

@@ -1056,8 +1058,7 @@ std::shared_ptr<arangodb::LogicalCollection> TRI_vocbase_t::lookupCollectionByUu
10561058
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
10571059
return itr == _dataSourceByUuid.end()
10581060
? nullptr
1059-
: std::dynamic_pointer_cast<arangodb::LogicalCollection>(itr->second)
1060-
;
1061+
: std::dynamic_pointer_cast<arangodb::LogicalCollection>(itr->second);
10611062
#else
10621063
return itr == _dataSourceByUuid.end()
10631064
|| itr->second->category() != LogicalCollection::category()
@@ -1113,18 +1114,34 @@ std::shared_ptr<arangodb::LogicalDataSource> TRI_vocbase_t::lookupDataSource(
11131114
std::shared_ptr<arangodb::LogicalView> TRI_vocbase_t::lookupView(
11141115
TRI_voc_cid_t id
11151116
) const noexcept {
1116-
return std::dynamic_pointer_cast<arangodb::LogicalView>(
1117-
lookupDataSource(id)
1118-
);
1117+
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
1118+
return std::dynamic_pointer_cast<arangodb::LogicalView>(
1119+
lookupDataSource(id)
1120+
);
1121+
#else
1122+
auto dataSource = lookupDataSource(id);
1123+
1124+
return dataSource && dataSource->category() == LogicalView::category()
1125+
? std::static_pointer_cast<LogicalView>(dataSource)
1126+
: nullptr;
1127+
#endif
11191128
}
11201129

11211130
/// @brief looks up a view by name or stringified cid or uuid
11221131
std::shared_ptr<arangodb::LogicalView> TRI_vocbase_t::lookupView(
11231132
std::string const& nameOrId
11241133
) const noexcept{
1125-
return std::dynamic_pointer_cast<arangodb::LogicalView>(
1126-
lookupDataSource(nameOrId)
1127-
);
1134+
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
1135+
return std::dynamic_pointer_cast<arangodb::LogicalView>(
1136+
lookupDataSource(nameOrId)
1137+
);
1138+
#else
1139+
auto dataSource = lookupDataSource(nameOrId);
1140+
1141+
return dataSource && dataSource->category() == LogicalView::category()
1142+
? std::static_pointer_cast<LogicalView>(dataSource)
1143+
: nullptr;
1144+
#endif
11281145
}
11291146

11301147
/// @brief creates a new collection from parameter set

0 commit comments

Comments
 (0)
0