From 6f307e62254b483f5040e5573e374dd04c3be73c Mon Sep 17 00:00:00 2001
From: Manuel Pietschmann <mpi@dresden-elektronik.de>
Date: Wed, 19 Jun 2024 16:00:36 +0200
Subject: [PATCH] Fix crash on macOS (#7817)

There are two bugs in one missing line.
After a new DDF is loaded during pairing the search must start from beginning of all loaded DDFs.
The actual crash happens when calling std::find_if with two end() iterators, but surprisingly only with Apple Clang, not with GCC on other platforms.

Issue: https://github.com/dresden-elektronik/deconz-rest-plugin/issues/7698
---
 device_descriptions.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/device_descriptions.cpp b/device_descriptions.cpp
index e2e5650e74..c09e7aa0e0 100644
--- a/device_descriptions.cpp
+++ b/device_descriptions.cpp
@@ -1083,8 +1083,6 @@ const DeviceDescription &DeviceDescriptions::get(const Resource *resource, DDF_M
 
     if (modelidAtomIndex == 0 || mfnameAtomIndex == 0)
     {
-        U_ASSERT(modelidItem->toString().isEmpty());
-        U_ASSERT(mfnameItem->toString().isEmpty());
         return d->invalidDescription; // happens when called from legacy init code addLightNode() etc.
     }
 
@@ -1121,6 +1119,7 @@ const DeviceDescription &DeviceDescriptions::get(const Resource *resource, DDF_M
                 // nothing found, try to load further DDFs
                 if (loadDDFAndBundlesFromDisc(resource))
                 {
+                    i = d->descriptions.begin();
                     continue; // found DDFs or bundles, try again
                 }
                 break;