Skip to content

Commit 7f5ce24

Browse files
OSS-Fuzz Teamcopybara-github
authored andcommitted
Protect from stack overflow in a pathological case of cyclic references
Indexer-PiperOrigin-RevId: 779011914
1 parent bd0d1e9 commit 7f5ce24

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

infra/indexer/index/in_memory_index.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ void ReportEntity(std::ostream& os, const Entity& entity,
148148
const Accessor<Entity, EntityId>& entities,
149149
const Accessor<Location, LocationId>& locations,
150150
int depth = 1) {
151+
if (depth > 5) {
152+
os << "...chain continues (a cycle?)...";
153+
return;
154+
}
151155
for (int i = 0; i < depth; ++i) {
152156
os << " ";
153157
}

0 commit comments

Comments
 (0)