mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-19 21:37:36 -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)
|
static int ensure_size(struct message *m, uint32_t size)
|
||||||
{
|
{
|
||||||
|
uint64_t needed;
|
||||||
uint32_t alloc, diff;
|
uint32_t alloc, diff;
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
|
|
@ -388,10 +389,10 @@ static int ensure_size(struct message *m, uint32_t size)
|
||||||
if (size <= m->allocated - m->length)
|
if (size <= m->allocated - m->length)
|
||||||
return size;
|
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;
|
return -ENOMEM;
|
||||||
|
alloc = (uint32_t)needed;
|
||||||
alloc = SPA_ROUND_UP_N(SPA_MAX(m->allocated + size, 4096u), 4096u);
|
|
||||||
diff = alloc - m->allocated;
|
diff = alloc - m->allocated;
|
||||||
if ((data = realloc(m->data, alloc)) == NULL) {
|
if ((data = realloc(m->data, alloc)) == NULL) {
|
||||||
free(m->data);
|
free(m->data);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue