summaryrefslogtreecommitdiffstats
path: root/winpr/libwinpr/utils/collections
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:25:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:25:11 +0000
commit941f9937e0744d18de4cc0afa71e0caa925d82ac (patch)
tree67872b86dbf72d73e91188bf8de12594668fe4aa /winpr/libwinpr/utils/collections
parentAdding upstream version 3.3.0+dfsg1. (diff)
downloadfreerdp3-941f9937e0744d18de4cc0afa71e0caa925d82ac.tar.xz
freerdp3-941f9937e0744d18de4cc0afa71e0caa925d82ac.zip
Adding upstream version 3.5.0+dfsg1.upstream/3.5.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'winpr/libwinpr/utils/collections')
-rw-r--r--winpr/libwinpr/utils/collections/CountdownEvent.c10
-rw-r--r--winpr/libwinpr/utils/collections/HashTable.c3
-rw-r--r--winpr/libwinpr/utils/collections/PubSub.c3
-rw-r--r--winpr/libwinpr/utils/collections/StreamPool.c2
4 files changed, 13 insertions, 5 deletions
diff --git a/winpr/libwinpr/utils/collections/CountdownEvent.c b/winpr/libwinpr/utils/collections/CountdownEvent.c
index fd23e0c..771ba54 100644
--- a/winpr/libwinpr/utils/collections/CountdownEvent.c
+++ b/winpr/libwinpr/utils/collections/CountdownEvent.c
@@ -48,7 +48,10 @@ struct CountdownEvent
size_t CountdownEvent_CurrentCount(wCountdownEvent* countdown)
{
WINPR_ASSERT(countdown);
- return countdown->count;
+ EnterCriticalSection(&countdown->lock);
+ const size_t rc = countdown->count;
+ LeaveCriticalSection(&countdown->lock);
+ return rc;
}
/**
@@ -58,7 +61,10 @@ size_t CountdownEvent_CurrentCount(wCountdownEvent* countdown)
size_t CountdownEvent_InitialCount(wCountdownEvent* countdown)
{
WINPR_ASSERT(countdown);
- return countdown->initialCount;
+ EnterCriticalSection(&countdown->lock);
+ const size_t rc = countdown->initialCount;
+ LeaveCriticalSection(&countdown->lock);
+ return rc;
}
/**
diff --git a/winpr/libwinpr/utils/collections/HashTable.c b/winpr/libwinpr/utils/collections/HashTable.c
index 7782b2b..8bbaf84 100644
--- a/winpr/libwinpr/utils/collections/HashTable.c
+++ b/winpr/libwinpr/utils/collections/HashTable.c
@@ -561,7 +561,8 @@ size_t HashTable_GetKeys(wHashTable* table, ULONG_PTR** ppKeys)
iKey = 0;
count = table->numOfElements;
- *ppKeys = NULL;
+ if (ppKeys)
+ *ppKeys = NULL;
if (count < 1)
{
diff --git a/winpr/libwinpr/utils/collections/PubSub.c b/winpr/libwinpr/utils/collections/PubSub.c
index 0efffb7..b95f26d 100644
--- a/winpr/libwinpr/utils/collections/PubSub.c
+++ b/winpr/libwinpr/utils/collections/PubSub.c
@@ -102,7 +102,7 @@ void PubSub_AddEventTypes(wPubSub* pubSub, wEventType* events, size_t count)
new_size = pubSub->size * 2;
new_event = (wEventType*)realloc(pubSub->events, new_size * sizeof(wEventType));
if (!new_event)
- return;
+ goto fail;
pubSub->size = new_size;
pubSub->events = new_event;
}
@@ -110,6 +110,7 @@ void PubSub_AddEventTypes(wPubSub* pubSub, wEventType* events, size_t count)
CopyMemory(&pubSub->events[pubSub->count], events, count * sizeof(wEventType));
pubSub->count += count;
+fail:
if (pubSub->synchronized)
PubSub_Unlock(pubSub);
}
diff --git a/winpr/libwinpr/utils/collections/StreamPool.c b/winpr/libwinpr/utils/collections/StreamPool.c
index 910309f..3ff113a 100644
--- a/winpr/libwinpr/utils/collections/StreamPool.c
+++ b/winpr/libwinpr/utils/collections/StreamPool.c
@@ -211,7 +211,7 @@ wStream* StreamPool_Take(wStreamPool* pool, size_t size)
if (!s)
goto out_fail;
}
- else
+ else if (s)
{
Stream_SetPosition(s, 0);
Stream_SetLength(s, Stream_Capacity(s));