[allocations] fix growth of preallocated buffers

* Replace * 2 with * sizeof(WCHAR) for string usages
* Grow streams and other buffers reasonably, e.g. add 128 elements per
  try and check for possible overflows
* Add constant postfix to force them to 64bit
This commit is contained in:
Armin Novak
2026-02-17 12:05:42 +01:00
parent fac35c3abb
commit 118afc0b95
28 changed files with 154 additions and 105 deletions

View File

@@ -28,10 +28,16 @@ BOOL android_push_event(freerdp* inst, ANDROID_EVENT* event)
if (aCtx->event_queue->count >= aCtx->event_queue->size)
{
int new_size;
void* new_events;
new_size = aCtx->event_queue->size * 2;
new_events = realloc((void*)aCtx->event_queue->events, sizeof(ANDROID_EVENT*) * new_size);
size_t new_size = aCtx->event_queue->size;
do
{
if (new_size >= SIZE_MAX - 128ull)
return FALSE;
new_size += 128ull;
} while (new_size <= aCtx->event_queue->count);
void* new_events =
realloc((void*)aCtx->event_queue->events, sizeof(ANDROID_EVENT*) * new_size);
if (!new_events)
return FALSE;