mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-20 06:46:31 -04:00
tools: fix realloc failure handling in midifile ensure_buffer
On realloc failure, the old mf->buffer pointer should be preserverd to avoid memory leaks.
This commit is contained in:
parent
61a9c78e1d
commit
d4b472d2e5
1 changed files with 6 additions and 1 deletions
|
|
@ -152,7 +152,12 @@ static uint8_t *ensure_buffer(struct midi_file *mf, struct midi_track *tr, size_
|
||||||
return tr->event;
|
return tr->event;
|
||||||
|
|
||||||
if (size > mf->buffer_size) {
|
if (size > mf->buffer_size) {
|
||||||
mf->buffer = realloc(mf->buffer, size);
|
uint8_t *newbuf = realloc(mf->buffer, size);
|
||||||
|
|
||||||
|
if (newbuf == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
mf->buffer = newbuf;
|
||||||
mf->buffer_size = size;
|
mf->buffer_size = size;
|
||||||
}
|
}
|
||||||
return mf->buffer;
|
return mf->buffer;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue