Skip to content

fix: missing mutex for bls::operator== #6722

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
30 changes: 17 additions & 13 deletions src/bls/bls.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,19 +509,23 @@ class CBLSLazyWrapper

bool operator==(const CBLSLazyWrapper& r) const
{
// If neither bufValid or objInitialized are set, then the object is the default object.
const bool is_default{!bufValid && !objInitialized};
const bool r_is_default{!r.bufValid && !r.objInitialized};
// If both are default; they are equal.
if (is_default && r_is_default) return true;
// If one is default and the other isn't, we are not equal
if (is_default != r_is_default) return false;

if (bufValid && r.bufValid && bufLegacyScheme == r.bufLegacyScheme) {
return vecBytes == r.vecBytes;
}
if (objInitialized && r.objInitialized) {
return obj == r.obj;
if (&r == this) return true;
{
std::scoped_lock lock(mutex, r.mutex);
// If neither bufValid or objInitialized are set, then the object is the default object.
const bool is_default{!bufValid && !objInitialized};
const bool r_is_default{!r.bufValid && !r.objInitialized};
// If both are default; they are equal.
if (is_default && r_is_default) return true;
// If one is default and the other isn't, we are not equal
if (is_default != r_is_default) return false;

if (bufValid && r.bufValid && bufLegacyScheme == r.bufLegacyScheme) {
return vecBytes == r.vecBytes;
}
if (objInitialized && r.objInitialized) {
return obj == r.obj;
}
}
return Get() == r.Get();
}
Expand Down
Loading