diff --git a/src/memberdef.cpp b/src/memberdef.cpp
index a25528a..dcbe19c 100644
--- a/src/memberdef.cpp
+++ b/src/memberdef.cpp
@@ -3784,6 +3784,9 @@ void MemberDef::writeEnumDeclaration(OutputList &typeDecl,
     {
       MemberListIterator mli(*fmdl);
       MemberDef *fmd=mli.current();
+      // mli.current() can return 0
+      if(!fmd)
+        return;
       bool fmdVisible = fmd->isBriefSectionVisible();
       while (fmd)
       {
