drm_prime: remove off by one when allocating new ref counter

This commit is contained in:
Kacper Michajłow 2024-05-07 13:15:36 +02:00
parent d1e55a0e87
commit 43b702d707
1 changed files with 3 additions and 4 deletions

View File

@ -130,10 +130,9 @@ void drm_prime_add_handle_ref(struct drm_prime_handle_refs *handle_refs,
if (handle) {
if (handle > handle_refs->size) {
MP_TARRAY_GROW(handle_refs->ctx, handle_refs->handle_ref_count,
handle);
memset(&handle_refs->handle_ref_count[handle_refs->size + 1], 0,
(handle - handle_refs->size)
* sizeof(handle_refs->handle_ref_count[0]));
handle - 1);
uint32_t *p = handle_refs->handle_ref_count;
memset(&p[handle_refs->size], 0, (handle - handle_refs->size) * sizeof(p[0]));
handle_refs->size = handle;
}
handle_refs->handle_ref_count[handle - 1]++;