Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion core/sourcehook/sourcehook_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,20 @@ namespace SourceHook

ICleanupTask *m_CleanupTask;

bool isValidIterator(List<CHook>::iterator &myIter, List<CHook> &myList) {
for (auto iter = myList.begin(); iter != myList.end(); ++iter) {
if (iter == myIter) {
return true;
}
}
return false;
}

Comment on lines +259 to +267
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inefficient, there are better ways to go about this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are the better ways? using this?

return myIter != myList.end() && std::distance(myList.begin(), myIter) >= 0;

void SkipPaused(List<CHook>::iterator &iter, List<CHook> &list)
{
while (iter != list.end() && iter->IsPaused())
if (!iter || !isValidIterator(iter, list))
Copy link
Member

@Kenzzer Kenzzer Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's your basis for believing iter can be null ? And if it is null, does checking only for that fixes your crash ? (I'm mainly hoping we can avoid having to iterate the entire the list)

Copy link
Author

@maxime1907 maxime1907 Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have edited my PR description to answer what you asked for

iter = list.end();
while (iter != list.end() && iter && iter->IsPaused())
++iter;
}
public:
Expand Down