mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-17 21:41:45 -04:00
pulse: also handle potential overflow in ROUND_UP
This commit is contained in:
parent
af151b088d
commit
79b4aba6cc
1 changed files with 4 additions and 3 deletions
|
|
@ -379,6 +379,7 @@ done:
|
|||
|
||||
static int ensure_size(struct message *m, uint32_t size)
|
||||
{
|
||||
uint64_t needed;
|
||||
uint32_t alloc, diff;
|
||||
void *data;
|
||||
|
||||
|
|
@ -388,10 +389,10 @@ static int ensure_size(struct message *m, uint32_t size)
|
|||
if (size <= m->allocated - m->length)
|
||||
return size;
|
||||
|
||||
if (m->allocated + size < m->allocated)
|
||||
needed = SPA_ROUND_UP_N(SPA_MAX((uint64_t)m->allocated + size, 4096u), 4096u);
|
||||
if (needed > UINT32_MAX)
|
||||
return -ENOMEM;
|
||||
|
||||
alloc = SPA_ROUND_UP_N(SPA_MAX(m->allocated + size, 4096u), 4096u);
|
||||
alloc = (uint32_t)needed;
|
||||
diff = alloc - m->allocated;
|
||||
if ((data = realloc(m->data, alloc)) == NULL) {
|
||||
free(m->data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue