From 401707879c60f09088ba69986115421d193705e7 Mon Sep 17 00:00:00 2001 From: trojanobelix Date: Fri, 28 Nov 2025 08:30:01 +0100 Subject: [PATCH] Check if the sub index for PDO mapping is still valid (might be deleted) Prevent crash if a mapped sub was deleted from OD. --- libEDSsharp/PDOHelper.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libEDSsharp/PDOHelper.cs b/libEDSsharp/PDOHelper.cs index 1b71d0db..181ae27e 100644 --- a/libEDSsharp/PDOHelper.cs +++ b/libEDSsharp/PDOHelper.cs @@ -366,8 +366,13 @@ void build_PDOlist(UInt16 startIdx, List slots) } else maptarget.entry = eds.ods[pdoindex].Getsubobject(pdosub); - - if ((maptarget.entry.prop.CO_disabled == false) && + // Check if mapped sub index was found in OD + if (maptarget.entry == null) + { + Console.WriteLine("MAPPING FAILED, OBJEKT NOT FOUND"); + continue; + } + else if ((maptarget.entry.prop.CO_disabled == false) && (datasize <= maptarget.entry.Sizeofdatatype()) && (datasize > 0)) {