Resolves: tdf#165295 partial cid#1555986 lock acquisition evasion revert

seeing as getTypeEntries can be reentrant

Change-Id: Ice119e2a48d4912722a35843bd1c5078805249bd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181799
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Caolán McNamara
2025-02-17 19:49:39 +00:00
parent 7ff861a1ea
commit 7a283ee554
3 changed files with 18 additions and 0 deletions

View File

@@ -97,6 +97,7 @@ static bool td_equals(typelib_TypeDescriptionReference const* pTDR1,
static cppu::type_entry* getTypeEntries(cppu::class_data* cd)
{
cppu::type_entry* pEntries = cd->m_typeEntries;
if (!cd->m_storedTypeRefs) // not inited?
{
static std::mutex aMutex;
std::scoped_lock guard(aMutex);
@@ -121,9 +122,14 @@ static cppu::type_entry* getTypeEntries(cppu::class_data* cd)
// ref is statically held by getCppuType()
pEntry->m_type.typeRef = rType.getTypeLibType();
}
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
cd->m_storedTypeRefs = true;
}
}
else
{
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
}
return pEntries;
}

View File

@@ -81,6 +81,7 @@ static bool td_equals(typelib_TypeDescriptionReference const* pTDR1,
static cppu::type_entry* getTypeEntries(cppu::class_data* cd)
{
cppu::type_entry* pEntries = cd->m_typeEntries;
if (!cd->m_storedTypeRefs) // not inited?
{
static std::mutex aMutex;
std::scoped_lock guard(aMutex);
@@ -105,9 +106,14 @@ static cppu::type_entry* getTypeEntries(cppu::class_data* cd)
// ref is statically held by getCppuType()
pEntry->m_type.typeRef = rType.getTypeLibType();
}
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
cd->m_storedTypeRefs = true;
}
}
else
{
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
}
return pEntries;
}

View File

@@ -64,6 +64,7 @@ static bool td_equals(
static type_entry * getTypeEntries( class_data * cd )
{
type_entry * pEntries = cd->m_typeEntries;
if (! cd->m_storedTypeRefs) // not inited?
{
static std::mutex aMutex;
std::scoped_lock guard( aMutex );
@@ -85,9 +86,14 @@ static type_entry * getTypeEntries( class_data * cd )
// ref is statically held by getCppuType()
pEntry->m_type.typeRef = rType.getTypeLibType();
}
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
cd->m_storedTypeRefs = true;
}
}
else
{
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
}
return pEntries;
}