summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-09-18 14:06:41 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-09-18 14:06:41 -0700
commit71ab94418ead8f59c6124e8b3e53f8df7340f095 (patch)
tree7ba9e8adf2e9781fa5551b568d3fe6c63eb06f0a
parent6f714830da6c8d74f024be6b0bb32c1ea39c1217 (diff)
set_gamma_info: remove unnecessary round-trip to serverHEADmaster
XRRGetCrtcGamma() returns the exact same size information as XRRGetCrtcGammaSize(), so just use it instead of waiting for the X server to send it an extra time. (And if something has gone very wrong so that they aren't the same, this avoids out-of-bounds reads processing the returned gamma arrays by using the size of the arrays we allocated.) Reported-by: Gregory James DUCK <gjduck@gmail.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--xrandr.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/xrandr.c b/xrandr.c
index 95a9988..3750e42 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -1063,17 +1063,12 @@ set_gamma_info(output_t *output)
if (!output->crtc_info)
return;
- size = XRRGetCrtcGammaSize(dpy, output->crtc_info->crtc.xid);
- if (!size) {
- warning("Failed to get size of gamma for output %s\n", output->output.string);
- return;
- }
-
crtc_gamma = XRRGetCrtcGamma(dpy, output->crtc_info->crtc.xid);
if (!crtc_gamma) {
warning("Failed to get gamma for output %s\n", output->output.string);
return;
}
+ size = crtc_gamma->size;
/*
* Here is a bit tricky because gamma is a whole curve for each