From f602f85a215b1c59c775f4b5ddb0669e48d01283 Mon Sep 17 00:00:00 2001 From: Mikhail Burakov Date: Tue, 14 Mar 2023 09:03:02 +0100 Subject: Fix GpuFrame destruction sequence --- gpu.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gpu.c b/gpu.c index 081acbe..43f61b7 100644 --- a/gpu.c +++ b/gpu.c @@ -547,16 +547,17 @@ bool GpuFrameConvert(const struct GpuFrame* from, const struct GpuFrame* to) { void GpuFrameDestroy(struct GpuFrame** gpu_frame) { if (!gpu_frame || !*gpu_frame) return; for (size_t i = LENGTH((*gpu_frame)->textures); i; i--) { - if ((*gpu_frame)->textures[i]) - glDeleteTextures(1, &(*gpu_frame)->textures[i]); + if ((*gpu_frame)->textures[i - 1]) + glDeleteTextures(1, &(*gpu_frame)->textures[i - 1]); } for (size_t i = LENGTH((*gpu_frame)->images); i; i--) { - if ((*gpu_frame)->images[i] != EGL_NO_IMAGE) + if ((*gpu_frame)->images[i - 1] != EGL_NO_IMAGE) eglDestroyImage((*gpu_frame)->gpu_context->display, - (*gpu_frame)->images[i]); + (*gpu_frame)->images[i - 1]); } for (size_t i = LENGTH((*gpu_frame)->dmabuf_fds); i; i--) { - if ((*gpu_frame)->dmabuf_fds[i] != -1) close((*gpu_frame)->dmabuf_fds[i]); + if ((*gpu_frame)->dmabuf_fds[i - 1] != -1) + close((*gpu_frame)->dmabuf_fds[i - 1]); } free(*gpu_frame); *gpu_frame = NULL; -- cgit v1.2.3