This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efl.

View the commit online.

commit ccdb1d77212f7c215a1af206c55e7522c22b345e
Author: Carsten Haitzler <ras...@rasterman.com>
AuthorDate: Sun Aug 25 09:20:16 2024 +0100

    ecore-x - fix ecore_x_randr_crtc_gamma_get to not return junk
    
    so... ecore_x_randr_crtc_gamma_get has been broken and probably worked
    by pure luck only as it freed the original xgamma struct but used the
    rgb array ptrs from it memcpy'ing them into ecore-x's struct. no one
    ever tested this much before it seems. fix it. necessary for future use.
    
    @fix
---
 src/lib/ecore_x/ecore_x_randr.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/lib/ecore_x/ecore_x_randr.c b/src/lib/ecore_x/ecore_x_randr.c
index 90be7afe38..ef3670d37f 100644
--- a/src/lib/ecore_x/ecore_x_randr.c
+++ b/src/lib/ecore_x/ecore_x_randr.c
@@ -2316,8 +2316,16 @@ ecore_x_randr_crtc_gamma_get(Ecore_X_Randr_Crtc crtc)
      return NULL;
 
    /* try to allocate space for the return struct and copy the results in */
-   if ((info = malloc(sizeof(Ecore_X_Randr_Crtc_Gamma_Info))))
-     memcpy(info, xgamma, sizeof(Ecore_X_Randr_Crtc_Gamma_Info));
+   if ((info = malloc(sizeof(Ecore_X_Randr_Crtc_Gamma_Info) + (xgamma->size * sizeof(unsigned short) * 3))))
+    {
+      info->size = xgamma->size;
+      info->red = (unsigned short *)(((char *)info) + sizeof(Ecore_X_Randr_Crtc_Gamma_Info));
+      info->green = info->red + xgamma->size;
+      info->blue = info->green + xgamma->size;
+      memcpy(info->red,   xgamma->red,   info->size * sizeof(unsigned short));
+      memcpy(info->green, xgamma->green, info->size * sizeof(unsigned short));
+      memcpy(info->blue,  xgamma->blue,  info->size * sizeof(unsigned short));
+    }
 
    /* free the returned gamma resource */
    XRRFreeGamma(xgamma);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to