8000 Check whether name is empty in getCollectionId{Local,Cluster} before … by markuspf · Pull Request #9309 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Check whether name is empty in getCollectionId{Local,Cluster} before … #9309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions arangod/Utils/CollectionNameResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,21 @@ std::shared_ptr<LogicalCollection> CollectionNameResolver::getCollection(std::st
//////////////////////////////////////////////////////////////////////////////

TRI_voc_cid_t CollectionNameResolver::getCollectionIdLocal(std::string const& name) const {
if (name[0] >= '0' && name[0] <= '9') {
if (name.empty()) {
return 0;
}

if (isdigit(name[0])) {
// name is a numeric id
return NumberUtils::atoi_zero<TRI_voc_cid_t>(name.data(), name.data() + name.size());
}

auto collection = getCollectionStruct(name);

if (collection != nullptr) {
return collection->id();
}

auto view = _vocbase.lookupView(name);

if (view) {
return view->id();
}
Expand All @@ -97,7 +99,10 @@ TRI_voc_cid_t CollectionNameResolver::getCollectionIdCluster(std::string const&
if (!ServerState::isRunningInCluster(_serverRole)) {
return getCollectionIdLocal(name);
}
if (name[0] >= '0' && name[0] <= '9') {
if (name.empty()) {
return 0;
}
if (isdigit(name[0])) {
// name is a numeric id
TRI_voc_cid_t cid =
NumberUtils::atoi_zero<TRI_voc_cid_t>(name.data(), name.data() + name.size());
Expand Down Expand Up @@ -131,6 +136,7 @@ TRI_voc_cid_t CollectionNameResolver::getCollectionIdCluster(std::string const&
return vinfo->id();
}
} catch (...) {
// TODO: ?
}

return 0;
Expand Down
0