From 668073787fa6b952d0f1520e8ccae0999dbdba13 Mon Sep 17 00:00:00 2001 From: Snowfall <70843164+R4ven47@users.noreply.github.com> Date: Tue, 30 Jan 2024 03:03:13 +0100 Subject: [PATCH] Linux/arm crash fix (segmentation fault): added a check to verify itemList validity (empty) (#3301) --- Shared/sdk/CFastList.h | 2 ++ Shared/sdk/SharedUtil.Misc.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Shared/sdk/CFastList.h b/Shared/sdk/CFastList.h index 7797e70cca..30f65a1eb0 100644 --- a/Shared/sdk/CFastList.h +++ b/Shared/sdk/CFastList.h @@ -307,6 +307,8 @@ class CFastList template bool ListContains(const CFastList& itemList, const U& item) { + if (itemList.empty()) + return false; return itemList.contains(item); } diff --git a/Shared/sdk/SharedUtil.Misc.h b/Shared/sdk/SharedUtil.Misc.h index 0d17a2f155..d64f155a7c 100644 --- a/Shared/sdk/SharedUtil.Misc.h +++ b/Shared/sdk/SharedUtil.Misc.h @@ -344,13 +344,14 @@ namespace SharedUtil template bool ListContains(const TL& itemList, const T& item) { + if (itemList.empty()) + return false; typename TL ::const_iterator it = itemList.begin(); for (; it != itemList.end(); ++it) if (item == *it) return true; return false; } - // Add item if it does not aleady exist in itemList template void ListAddUnique(TL& itemList, const T& item)