Skip to content

Commit 6680737

Browse files
authored
Linux/arm crash fix (segmentation fault): added a check to verify itemList validity (empty) (#3301)
1 parent a3c6f0f commit 6680737

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Shared/sdk/CFastList.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ class CFastList
307307
template <class T, class U>
308308
bool ListContains(const CFastList<T*>& itemList, const U& item)
309309
{
310+
if (itemList.empty())
311+
return false;
310312
return itemList.contains(item);
311313
}
312314

Shared/sdk/SharedUtil.Misc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,14 @@ namespace SharedUtil
344344
template <class TL, class T>
345345
bool ListContains(const TL& itemList, const T& item)
346346
{
347+
if (itemList.empty())
348+
return false;
347349
typename TL ::const_iterator it = itemList.begin();
348350
for (; it != itemList.end(); ++it)
349351
if (item == *it)
350352
return true;
351353
return false;
352354
}
353-
354355
// Add item if it does not aleady exist in itemList
355356
template <class TL, class T>
356357
void ListAddUnique(TL& itemList, const T& item)

0 commit comments

Comments
 (0)