frontends/va: Fix leaks with multiple coded buffer segments
The buffers can be reused, so we must only allocate added segments
and free unused segments.
Fixes: be4287c3aa
("pipe: Extend get_feedback with additional metadata")
Reviewed-By: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30779>
This commit is contained in:
@@ -216,11 +216,20 @@ VAStatus vlVaMapBuffer2(VADriverContextP ctx, VABufferID buf_id,
|
||||
*pbuff = buf->data;
|
||||
|
||||
for (size_t i = 0; i < buf->extended_metadata.codec_unit_metadata_count - 1; i++) {
|
||||
curr_buf_ptr->next = CALLOC(1, sizeof(VACodedBufferSegment));
|
||||
if (!curr_buf_ptr->next)
|
||||
curr_buf_ptr->next = CALLOC(1, sizeof(VACodedBufferSegment));
|
||||
if (!curr_buf_ptr->next)
|
||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
curr_buf_ptr = curr_buf_ptr->next;
|
||||
}
|
||||
if (curr_buf_ptr->next) {
|
||||
VACodedBufferSegment *node = curr_buf_ptr->next;
|
||||
while (node) {
|
||||
VACodedBufferSegment *next = node->next;
|
||||
FREE(node);
|
||||
node = next;
|
||||
}
|
||||
}
|
||||
curr_buf_ptr->next = NULL;
|
||||
|
||||
curr_buf_ptr = buf->data;
|
||||
|
Reference in New Issue
Block a user