Commit 69a600b00e9eb157b418c4f004d72babfd3ba8d2

Cacodemon345 2021-02-26T22:24:48

Implement requested changes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index d9850fe..e157378 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -1373,8 +1373,13 @@ KMSDRM_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
     SDL_VideoData *viddata = (SDL_VideoData*)windata->viddata;
     SDL_VideoDisplay *disp = SDL_GetDisplayForWindow(window);
     SDL_DisplayData* dispdata = (SDL_DisplayData*)disp->driverdata;
-    Uint16* tempRamp = SDL_calloc(3 * 2,256);
-    SDL_memcpy(tempRamp,ramp,3 * 2 * 256);
+    Uint16* tempRamp = SDL_calloc(3 * sizeof(Uint16),256);
+    if (tempRamp == NULL)
+    {
+        SDL_OutOfMemory();
+        return -1;
+    }
+    SDL_memcpy(tempRamp,ramp,3 * sizeof(Uint16) * 256);
     if (KMSDRM_drmModeCrtcSetGamma(viddata->drm_fd, dispdata->crtc->crtc_id, 256, &tempRamp[0*256], &tempRamp[1*256], &tempRamp[2*256]) == -1)
     {
         SDL_free(tempRamp);