From 260da0d01567b67c2f76600996d4760cdab72635 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9goire=20KUBLER?= <gregoire.kubler@proton.me>
Date: Thu, 24 Oct 2024 13:46:58 +0200
Subject: [PATCH] fix : added an assert to ensure that specs were effectively
 retrieved by getAvailableSpecs

otherwise dereferencing bestMatch later on in the function resulted in a segfault
---
 src/backend/OperatorImpl.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/backend/OperatorImpl.cpp b/src/backend/OperatorImpl.cpp
index dd5c5c110..1708d9e36 100644
--- a/src/backend/OperatorImpl.cpp
+++ b/src/backend/OperatorImpl.cpp
@@ -95,6 +95,10 @@ Aidge::ImplSpec Aidge::OperatorImpl::getBestMatch(const ImplSpec& requiredSpecs)
     Log::debug("getBestMatch() for requirements: {}", requiredSpecs);
 
     const auto availableSpecsSet = getAvailableImplSpecs();
+    AIDGE_ASSERT(availableSpecsSet.size() > 0 , 
+                 "OperatorImpl::getBestMatch(): No available specs found by"
+                 "getAvailableSpecs(). "
+                 "Cannot find best implementation for required specs, aborting.");
     const std::vector<ImplSpec> availableSpecs(availableSpecsSet.begin(), availableSpecsSet.end());
     std::vector<int> matchingSpecs(availableSpecs.size(), -1);
 
-- 
GitLab