From 9de59297b586d89f0ea8fbeae0269873f84d778a Mon Sep 17 00:00:00 2001
From: Laurent Pugin <lxpugin@gmail.com>
Date: Wed, 25 Oct 2023 08:51:17 -0400
Subject: [PATCH] Fix seg fault with `syllable` used in non neume staves

---
 src/alignfunctor.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/alignfunctor.cpp b/src/alignfunctor.cpp
index 93c9d2ad944..c862fadf1aa 100644
--- a/src/alignfunctor.cpp
+++ b/src/alignfunctor.cpp
@@ -264,12 +264,11 @@ FunctorCode AlignHorizontallyFunctor::VisitLayerElement(LayerElement *layerEleme
     }
     else if (layerElement->Is(SYL)) {
         Staff *staff = layerElement->GetAncestorStaff();
-        if (staff->m_drawingNotationType == NOTATIONTYPE_neume) {
+        Note *note = vrv_cast<Note *>(layerElement->GetFirstAncestor(NOTE));
+        if (!note || (staff->m_drawingNotationType == NOTATIONTYPE_neume)) {
             type = ALIGNMENT_DEFAULT;
         }
         else {
-            Note *note = vrv_cast<Note *>(layerElement->GetFirstAncestor(NOTE));
-            assert(note);
             layerElement->SetAlignment(note->GetAlignment());
         }
     }