diff --git a/src/index.cpp b/src/index.cpp
index ff347e3..c8996e7 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -926,7 +926,7 @@ static int countClassesInTreeList(const ClassSDict &cl)
   for (;cli.current(); ++cli)
   {
     ClassDef *cd=cli.current();
-    if (!hasVisibleRoot(cd->baseClasses())) // filter on root classes
+    if (cd && !hasVisibleRoot(cd->baseClasses())) // filter on root classes
     {
       if (cd->isVisibleInHierarchy()) // should it be visible
       {
