mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[winpr] fix InitializeCriticalSectionAndSpinCount
Check return values when used.
This commit is contained in:
@@ -495,7 +495,12 @@ static int bio_rdp_tls_new(BIO* bio)
|
|||||||
if (!(tls = calloc(1, sizeof(BIO_RDP_TLS))))
|
if (!(tls = calloc(1, sizeof(BIO_RDP_TLS))))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
InitializeCriticalSectionAndSpinCount(&tls->lock, 4000);
|
if (!InitializeCriticalSectionAndSpinCount(&tls->lock, 4000))
|
||||||
|
{
|
||||||
|
free(tls);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
BIO_set_data(bio, (void*)tls);
|
BIO_set_data(bio, (void*)tls);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,9 +152,15 @@ static DWORD WINAPI TestSynchCritical_Main(LPVOID arg)
|
|||||||
DeleteCriticalSection(&critical);
|
DeleteCriticalSection(&critical);
|
||||||
|
|
||||||
if (dwSpinCount % 2 == 0)
|
if (dwSpinCount % 2 == 0)
|
||||||
InitializeCriticalSectionAndSpinCount(&critical, dwSpinCount);
|
{
|
||||||
|
if (!InitializeCriticalSectionAndSpinCount(&critical, dwSpinCount))
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
InitializeCriticalSectionEx(&critical, dwSpinCount, 0);
|
{
|
||||||
|
if (!InitializeCriticalSectionEx(&critical, dwSpinCount, 0))
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
DeleteCriticalSection(&critical);
|
DeleteCriticalSection(&critical);
|
||||||
|
|
||||||
@@ -229,7 +235,8 @@ static DWORD WINAPI TestSynchCritical_Main(LPVOID arg)
|
|||||||
for (int j = 0; j < TEST_SYNC_CRITICAL_TEST1_RUNS; j++)
|
for (int j = 0; j < TEST_SYNC_CRITICAL_TEST1_RUNS; j++)
|
||||||
{
|
{
|
||||||
dwSpinCount = j * 100;
|
dwSpinCount = j * 100;
|
||||||
InitializeCriticalSectionAndSpinCount(&critical, dwSpinCount);
|
if (!InitializeCriticalSectionAndSpinCount(&critical, dwSpinCount))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
gTestValueVulnerable = 0;
|
gTestValueVulnerable = 0;
|
||||||
gTestValueSerialized = 0;
|
gTestValueSerialized = 0;
|
||||||
|
|||||||
@@ -591,7 +591,8 @@ wArrayList* ArrayList_New(BOOL synchronized)
|
|||||||
if (!ArrayList_EnsureCapacity(arrayList, 32))
|
if (!ArrayList_EnsureCapacity(arrayList, 32))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
InitializeCriticalSectionAndSpinCount(&arrayList->lock, 4000);
|
if (!InitializeCriticalSectionAndSpinCount(&arrayList->lock, 4000))
|
||||||
|
goto fail;
|
||||||
return arrayList;
|
return arrayList;
|
||||||
fail:
|
fail:
|
||||||
WINPR_PRAGMA_DIAG_PUSH
|
WINPR_PRAGMA_DIAG_PUSH
|
||||||
|
|||||||
@@ -523,7 +523,10 @@ wBufferPool* BufferPool_New(BOOL synchronized, SSIZE_T fixedSize, DWORD alignmen
|
|||||||
pool->synchronized = synchronized;
|
pool->synchronized = synchronized;
|
||||||
|
|
||||||
if (pool->synchronized)
|
if (pool->synchronized)
|
||||||
InitializeCriticalSectionAndSpinCount(&pool->lock, 4000);
|
{
|
||||||
|
if (!InitializeCriticalSectionAndSpinCount(&pool->lock, 4000))
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
if (pool->fixedSize)
|
if (pool->fixedSize)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -765,7 +765,8 @@ wHashTable* HashTable_New(BOOL synchronized)
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
table->synchronized = synchronized;
|
table->synchronized = synchronized;
|
||||||
InitializeCriticalSectionAndSpinCount(&(table->lock), 4000);
|
if (!InitializeCriticalSectionAndSpinCount(&(table->lock), 4000))
|
||||||
|
goto fail;
|
||||||
table->numOfBuckets = 64;
|
table->numOfBuckets = 64;
|
||||||
table->numOfElements = 0;
|
table->numOfElements = 0;
|
||||||
table->bucketArray = (wKeyValuePair**)calloc(table->numOfBuckets, sizeof(wKeyValuePair*));
|
table->bucketArray = (wKeyValuePair**)calloc(table->numOfBuckets, sizeof(wKeyValuePair*));
|
||||||
|
|||||||
@@ -168,7 +168,13 @@ wObjectPool* ObjectPool_New(BOOL synchronized)
|
|||||||
pool->synchronized = synchronized;
|
pool->synchronized = synchronized;
|
||||||
|
|
||||||
if (pool->synchronized)
|
if (pool->synchronized)
|
||||||
InitializeCriticalSectionAndSpinCount(&pool->lock, 4000);
|
{
|
||||||
|
if (!InitializeCriticalSectionAndSpinCount(&pool->lock, 4000))
|
||||||
|
{
|
||||||
|
free(pool);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pool;
|
return pool;
|
||||||
|
|||||||
@@ -414,7 +414,8 @@ wStreamPool* StreamPool_New(BOOL synchronized, size_t defaultSize)
|
|||||||
if (!StreamPool_EnsureCapacity(pool, 32, TRUE))
|
if (!StreamPool_EnsureCapacity(pool, 32, TRUE))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
InitializeCriticalSectionAndSpinCount(&pool->lock, 4000);
|
if (!InitializeCriticalSectionAndSpinCount(&pool->lock, 4000))
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pool;
|
return pool;
|
||||||
|
|||||||
@@ -144,7 +144,11 @@ static wLogAppender* WLog_Appender_New(wLog* log, DWORD logAppenderType)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeCriticalSectionAndSpinCount(&appender->lock, 4000);
|
if (!InitializeCriticalSectionAndSpinCount(&appender->lock, 4000))
|
||||||
|
{
|
||||||
|
WLog_Appender_Free(log, appender);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
return appender;
|
return appender;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -921,7 +921,8 @@ wLog* WLog_New(LPCSTR name, wLog* rootLogger)
|
|||||||
goto out_fail;
|
goto out_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeCriticalSectionAndSpinCount(&log->lock, 4000);
|
if (!InitializeCriticalSectionAndSpinCount(&log->lock, 4000))
|
||||||
|
goto out_fail;
|
||||||
|
|
||||||
return log;
|
return log;
|
||||||
out_fail:
|
out_fail:
|
||||||
|
|||||||
Reference in New Issue
Block a user