mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user