diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 7da23941b6..4c8899a34b 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -179,7 +179,7 @@ void InsetRef::addToToc(Buffer const & buf, // The Toc item for this label already exists so let's add // this inset to this node. ++it; - while (it->str() == reflabel && it != end) + while (it != end || it->str() == reflabel) ++it; toc.insert(it, TocItem(cpit, 1, reflabel)); }