From e1d932f8b66bcc2580e283606167cb4a541e99e2 Mon Sep 17 00:00:00 2001 From: Manuel Alfayate Corchete Date: Sun, 17 Jan 2021 21:33:51 +0100 Subject: [PATCH] [KMS/DRM] Fix for bug #5468: corruption on dynamic cursor changing caused by wrong buffer size. --- src/video/kmsdrm/SDL_kmsdrmmouse.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c index 2937cb787..25d3db975 100644 --- a/src/video/kmsdrm/SDL_kmsdrmmouse.c +++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c @@ -242,17 +242,15 @@ KMSDRM_ShowCursor(SDL_Cursor * cursor) /* Prepare a buffer we can dump to our GBM BO (different size, alpha premultiplication...) */ bo_stride = KMSDRM_gbm_bo_get_stride(dispdata->cursor_bo); - bufsize = bo_stride * curdata->h; + bufsize = bo_stride * dispdata->cursor_h; + + ready_buffer = (uint32_t*)SDL_calloc(1, bufsize); - ready_buffer = (uint32_t*)SDL_malloc(bufsize); if (!ready_buffer) { ret = SDL_OutOfMemory(); goto cleanup; } - /* Clean the whole buffer we are preparing. */ - SDL_memset(ready_buffer, 0x00, bo_stride * curdata->h); - /* Copy from the cursor buffer to a buffer that we can dump to the GBM BO, pre-multiplying by alpha each pixel as we go. */ for (i = 0; i < curdata->h; i++) {