aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2017-11-09 10:21:20 +0100
committerMihai Moldovan <ionic@ionic.de>2017-12-07 07:20:55 +0100
commit4e059d5798f8c0f686c4ef5cec0f6c98ff6d5646 (patch)
treeed1b3acfedea2910e78a42b8cb567f362acef104 /nx-X11/programs/Xserver
parentc571aa9eda7d69b3de1647a208c685a971c9ad38 (diff)
downloadnx-libs-4e059d5798f8c0f686c4ef5cec0f6c98ff6d5646.tar.gz
nx-libs-4e059d5798f8c0f686c4ef5cec0f6c98ff6d5646.tar.bz2
nx-libs-4e059d5798f8c0f686c4ef5cec0f6c98ff6d5646.zip
randr: always realloc crtcs and outputs
Backported from X.org: commit 16381d186e7c791031392ed8afcfd33009854e9e Author: Giuseppe Bilotta giuseppe.bilotta@gmail.com Date: Thu Nov 9 10:21:20 2017 +0100 randr: always realloc crtcs and outputs When the last crtc (resp. output) is destroyed, the rrScrPriv crtcs (resp. outputs) fields do not get cleared, which can lead to a situation where the private's numCrtcs (resp. numOutputs) field is zero, but the associated memory is still allocated. Just checking if numCrtcs (resp. numOutputs) is zero is thus not a good criteria to determine whetehr to use a realloc or a malloc. Since crtcs (resp. outputs) are NULL-initialized anyway, relying on numCrtcs (resp. numOutputs) is actually unnecessary, because reallocation of a NULL ptr is equivalent to a malloc anyway. Therefore, just use realloc() unconditionally, and ensure that the fields are properly initialized. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de> Fixes ArcticaProject/nx-libs#558
Diffstat (limited to 'nx-X11/programs/Xserver')
-rw-r--r--nx-X11/programs/Xserver/randr/rrcrtc.c9
-rw-r--r--nx-X11/programs/Xserver/randr/rroutput.c9
2 files changed, 6 insertions, 12 deletions
diff --git a/nx-X11/programs/Xserver/randr/rrcrtc.c b/nx-X11/programs/Xserver/randr/rrcrtc.c
index 7775747f8..1305132c0 100644
--- a/nx-X11/programs/Xserver/randr/rrcrtc.c
+++ b/nx-X11/programs/Xserver/randr/rrcrtc.c
@@ -89,13 +89,10 @@ RRCrtcCreate(ScreenPtr pScreen, void *devPrivate)
pScrPriv = rrGetScrPriv(pScreen);
/* make space for the crtc pointer */
- if (pScrPriv->numCrtcs)
- crtcs = reallocarray(pScrPriv->crtcs,
- pScrPriv->numCrtcs + 1, sizeof(RRCrtcPtr));
- else
- crtcs = malloc(sizeof(RRCrtcPtr));
+ crtcs = reallocarray(pScrPriv->crtcs,
+ pScrPriv->numCrtcs + 1, sizeof(RRCrtcPtr));
if (!crtcs)
- return FALSE;
+ return NULL;
pScrPriv->crtcs = crtcs;
crtc = calloc(1, sizeof(RRCrtcRec));
diff --git a/nx-X11/programs/Xserver/randr/rroutput.c b/nx-X11/programs/Xserver/randr/rroutput.c
index 8042b719c..9c52eaed6 100644
--- a/nx-X11/programs/Xserver/randr/rroutput.c
+++ b/nx-X11/programs/Xserver/randr/rroutput.c
@@ -74,13 +74,10 @@ RROutputCreate(ScreenPtr pScreen,
pScrPriv = rrGetScrPriv(pScreen);
- if (pScrPriv->numOutputs)
- outputs = reallocarray(pScrPriv->outputs,
- pScrPriv->numOutputs + 1, sizeof(RROutputPtr));
- else
- outputs = malloc(sizeof(RROutputPtr));
+ outputs = reallocarray(pScrPriv->outputs,
+ pScrPriv->numOutputs + 1, sizeof(RROutputPtr));
if (!outputs)
- return FALSE;
+ return NULL;
pScrPriv->outputs = outputs;