Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a crash when searching the first enabled bit in a completely disabled bit array #2381

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Changes from 2 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
5 changes: 5 additions & 0 deletions MoltenVK/MoltenVK/Utility/MVKBitArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include "MVKFoundation.h"
#include <functional>
billhollings marked this conversation as resolved.
Show resolved Hide resolved


#pragma mark -
Expand Down Expand Up @@ -104,6 +105,10 @@ class MVKBitArray {
secIdx = _fullyDisabledSectionCount;
startIndex = 0;
}
/* If all bits are disabled and the number of bits is precisely a multiple of SectionBitCount,
* then we'd be trying to access a section that doesn't exist, so we must bail out immediately. */
if (secIdx >= getSectionCount())
return _bitCount;
billhollings marked this conversation as resolved.
Show resolved Hide resolved
return std::min((secIdx * SectionBitCount) + getIndexOfFirstEnabledBitInSection(getSection(secIdx), getBitIndexInSection(startIndex)), _bitCount);
}

Expand Down
Loading