@@ -509,19 +509,23 @@ class CBLSLazyWrapper
509509
510510 bool operator ==(const CBLSLazyWrapper& r) const
511511 {
512- // If neither bufValid or objInitialized are set, then the object is the default object.
513- const bool is_default{!bufValid && !objInitialized};
514- const bool r_is_default{!r.bufValid && !r.objInitialized };
515- // If both are default; they are equal.
516- if (is_default && r_is_default) return true ;
517- // If one is default and the other isn't, we are not equal
518- if (is_default != r_is_default) return false ;
519-
520- if (bufValid && r.bufValid && bufLegacyScheme == r.bufLegacyScheme ) {
521- return vecBytes == r.vecBytes ;
522- }
523- if (objInitialized && r.objInitialized ) {
524- return obj == r.obj ;
512+ if (&r == this ) return true ;
513+ {
514+ std::scoped_lock lock (mutex, r.mutex );
515+ // If neither bufValid or objInitialized are set, then the object is the default object.
516+ const bool is_default{!bufValid && !objInitialized};
517+ const bool r_is_default{!r.bufValid && !r.objInitialized };
518+ // If both are default; they are equal.
519+ if (is_default && r_is_default) return true ;
520+ // If one is default and the other isn't, we are not equal
521+ if (is_default != r_is_default) return false ;
522+
523+ if (bufValid && r.bufValid && bufLegacyScheme == r.bufLegacyScheme ) {
524+ return vecBytes == r.vecBytes ;
525+ }
526+ if (objInitialized && r.objInitialized ) {
527+ return obj == r.obj ;
528+ }
525529 }
526530 return Get () == r.Get ();
527531 }
0 commit comments