From 4e059d5798f8c0f686c4ef5cec0f6c98ff6d5646 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 9 Nov 2017 10:21:20 +0100 Subject: 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 Signed-off-by: Giuseppe Bilotta Backported-to-NX-by: Ulrich Sibiller Fixes ArcticaProject/nx-libs#558 --- nx-X11/programs/Xserver/randr/rrcrtc.c | 9 +++------ nx-X11/programs/Xserver/randr/rroutput.c | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) (limited to 'nx-X11/programs/Xserver') 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; -- cgit v1.2.3 From 6f9a6aacd70685ae0c468df2441cf77627c3e5ee Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 9 Nov 2017 10:21:21 +0100 Subject: randr: free crtc->outputs on destroy Backported from X.org: commit fc7fb5bbe1c8f787e53500b9a2ca4af815f310d1 Author: Giuseppe Bilotta giuseppe.bilotta@gmail.com Date: Thu Nov 9 10:21:21 2017 +0100 randr: free crtc->outputs on destroy Reviewed-by: Adam Jackson Signed-off-by: Giuseppe Bilotta Backported-to-NX-by: Ulrich Sibiller Fixes ArcticaProject/nx-libs#558 --- nx-X11/programs/Xserver/randr/rrcrtc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'nx-X11/programs/Xserver') diff --git a/nx-X11/programs/Xserver/randr/rrcrtc.c b/nx-X11/programs/Xserver/randr/rrcrtc.c index 1305132c0..20ab73c5b 100644 --- a/nx-X11/programs/Xserver/randr/rrcrtc.c +++ b/nx-X11/programs/Xserver/randr/rrcrtc.c @@ -769,6 +769,7 @@ RRCrtcDestroyResource(void *value, XID pid) free(crtc->gammaRed); if (crtc->mode) RRModeDestroy(crtc->mode); + free(crtc->outputs); free(crtc); return 1; } -- cgit v1.2.3 From 43388104df08858c13af7994392581e0ad6a4e4b Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Wed, 15 Mar 2006 16:49:04 +0000 Subject: Coverity # 807: Fix a memory leak in XFixesExpandRegion. Backported from X.org: commit 5e106a71b9f8077216d41619402952b0005dd8a4 Author: Adam Jackson Date: Wed Mar 15 16:49:04 2006 +0000 Coverity # 807: Fix a memory leak in XFixesExpandRegion. Backported-to-NX-by: Ulrich Sibiller Fixes ArcticaProject/nx-libs#541 --- nx-X11/programs/Xserver/xfixes/region.c | 1 + 1 file changed, 1 insertion(+) (limited to 'nx-X11/programs/Xserver') diff --git a/nx-X11/programs/Xserver/xfixes/region.c b/nx-X11/programs/Xserver/xfixes/region.c index 31d19b5ff..18b1d3ff4 100644 --- a/nx-X11/programs/Xserver/xfixes/region.c +++ b/nx-X11/programs/Xserver/xfixes/region.c @@ -817,6 +817,7 @@ ProcXFixesExpandRegion (ClientPtr client) RegionInit(&r, &pTmp[i], 0); RegionUnion(pDestination, pDestination, &r); } + free(pTmp); } if (ret == Success) ret = client->noClientException; -- cgit v1.2.3 From d31f107c63a7f6c13c212ade8172bcdb63faee2e Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Wed, 15 Mar 2006 16:33:12 +0000 Subject: Coverity # 487: Check version number correctly. Backported from X.org: commit 152090ce442e94de1ae920208a92931af6493c8c Author: Adam Jackson Date: Wed Mar 15 16:33:12 2006 +0000 Coverity # 487: Check version number correctly. Backported-to-NX-by: Ulrich Sibiller Fixes ArcticaProject/nx-libs#542 --- nx-X11/programs/Xserver/xfixes/xfixes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/programs/Xserver') diff --git a/nx-X11/programs/Xserver/xfixes/xfixes.c b/nx-X11/programs/Xserver/xfixes/xfixes.c index add8d1b0e..1403be8c5 100644 --- a/nx-X11/programs/Xserver/xfixes/xfixes.c +++ b/nx-X11/programs/Xserver/xfixes/xfixes.c @@ -120,7 +120,7 @@ ProcXFixesDispatch (ClientPtr client) REQUEST(xXFixesReq); XFixesClientPtr pXFixesClient = GetXFixesClient (client); - if (pXFixesClient->major_version > NUM_VERSION_REQUESTS) + if (pXFixesClient->major_version >= NUM_VERSION_REQUESTS) return BadRequest; if (stuff->xfixesReqType > version_requests[pXFixesClient->major_version]) return BadRequest; -- cgit v1.2.3 From 1771deaf134e3e93bf4f3242a6e613b645e96a52 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 5 Dec 2017 22:06:11 +0100 Subject: Coverity # 491: Check version number correctly. Backported from X.org: commit 72cc6307257fcbb800267464487bf918ee674328 Author: Adam Jackson Date: Wed Mar 15 16:32:05 2006 +0000 Coverity # 491: Check version number correctly. Backported-to-NX-by: Ulrich Sibiller --- nx-X11/programs/Xserver/damageext/damageext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/programs/Xserver') diff --git a/nx-X11/programs/Xserver/damageext/damageext.c b/nx-X11/programs/Xserver/damageext/damageext.c index b5e5d0b00..b9d99a53c 100644 --- a/nx-X11/programs/Xserver/damageext/damageext.c +++ b/nx-X11/programs/Xserver/damageext/damageext.c @@ -296,7 +296,7 @@ ProcDamageDispatch (ClientPtr client) REQUEST(xDamageReq); DamageClientPtr pDamageClient = GetDamageClient (client); - if (pDamageClient->major_version > NUM_VERSION_REQUESTS) + if (pDamageClient->major_version >= NUM_VERSION_REQUESTS) return BadRequest; if (stuff->damageReqType > version_requests[pDamageClient->major_version]) return BadRequest; -- cgit v1.2.3 From 0a010adfc2717200e3f2acf345ef2802cfaaa146 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 5 Dec 2017 22:09:06 +0100 Subject: Coverity # 337: Remove useless NULL check. Backported from X.org: Commit 6bb2dc02a7cffd6ed7dd28e88d584920a4150749 Author: Adam Jackson Date: Wed Mar 15 16:01:47 2006 +0000 Coverity # 337: Remove useless NULL check. Backported-to-NX-by: Ulrich Sibiller --- nx-X11/programs/Xserver/miext/cw/cw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/programs/Xserver') diff --git a/nx-X11/programs/Xserver/miext/cw/cw.c b/nx-X11/programs/Xserver/miext/cw/cw.c index d9ca55f7e..a45c34dff 100644 --- a/nx-X11/programs/Xserver/miext/cw/cw.c +++ b/nx-X11/programs/Xserver/miext/cw/cw.c @@ -463,7 +463,7 @@ cwPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what) DrawablePtr pBackingDrawable; int x_off, y_off, x_screen, y_screen; - while (pWin && pWin->backgroundState == ParentRelative) + while (pWin->backgroundState == ParentRelative) pWin = pWin->parent; pBackingDrawable = cwGetBackingDrawable((DrawablePtr)pWin, &x_off, -- cgit v1.2.3 From e073093cc9ea46eb1740440d286c2874b98fd3ae Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 5 Dec 2017 22:14:22 +0100 Subject: devPrivates fixes Backported from X.Org: commit 0693083335185ce05ee64546151f3fc43ce98575 Author: Lars Knoll Date: Mon Mar 6 21:00:09 2006 +0000 render/picture.c Correctly initialize devPrivates variable in source only pictures to 0 miext/cw/cw.h Don't try to access devPrivates of source only pictures Backported-from-NX-by: Ulrich Sibiller --- nx-X11/programs/Xserver/miext/cw/cw.h | 3 ++- nx-X11/programs/Xserver/render/picture.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'nx-X11/programs/Xserver') diff --git a/nx-X11/programs/Xserver/miext/cw/cw.h b/nx-X11/programs/Xserver/miext/cw/cw.h index de4746be6..b8792661f 100644 --- a/nx-X11/programs/Xserver/miext/cw/cw.h +++ b/nx-X11/programs/Xserver/miext/cw/cw.h @@ -60,7 +60,8 @@ typedef struct { unsigned long stateChanges; } cwPictureRec, *cwPicturePtr; -#define getCwPicture(pPicture) ((cwPicturePtr)(pPicture)->devPrivates[cwPictureIndex].ptr) +#define getCwPicture(pPicture) \ + (pPicture->pDrawable ? (cwPicturePtr)(pPicture)->devPrivates[cwPictureIndex].ptr : 0) #define setCwPicture(pPicture,p) ((pPicture)->devPrivates[cwPictureIndex].ptr = (void *) (p)) extern int cwPictureIndex; diff --git a/nx-X11/programs/Xserver/render/picture.c b/nx-X11/programs/Xserver/render/picture.c index e82319bc9..eba042903 100644 --- a/nx-X11/programs/Xserver/render/picture.c +++ b/nx-X11/programs/Xserver/render/picture.c @@ -982,6 +982,7 @@ static PicturePtr createSourcePicture(void) pPicture->pDrawable = 0; pPicture->pFormat = 0; pPicture->pNext = 0; + pPicture->devPrivates = 0; SetPictureToDefaults(pPicture); return pPicture; -- cgit v1.2.3 From e05b90814984e65bac2dc602bc368b2046a7b92e Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 5 Dec 2017 22:22:55 +0100 Subject: Allow options to appear with other components. Backported from X.Org: commit 1cfa9f647e0241f4b9e56556b128d7bfd987eaca Author: Daniel Stone Date: Tue Feb 28 16:55:26 2006 +0000 Bug # 5216: Allow options to appear with other components. Backported-to-NX-by: Ulrich Sibiller --- nx-X11/programs/Xserver/xkb/maprules.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'nx-X11/programs/Xserver') diff --git a/nx-X11/programs/Xserver/xkb/maprules.c b/nx-X11/programs/Xserver/xkb/maprules.c index 337c8634b..de52aa4b5 100644 --- a/nx-X11/programs/Xserver/xkb/maprules.c +++ b/nx-X11/programs/Xserver/xkb/maprules.c @@ -358,13 +358,6 @@ Bool found; remap->num_remap= 0; return; } - if (((present&PART_MASK)&(1<num_remap= 0; - return; - } if (((present&COMPONENT_MASK)&(1< Date: Tue, 5 Dec 2017 22:39:34 +0100 Subject: DIX: XKB: Set xkbInfo to NULL as well as freeing it Backported from X.org: commit 512bac25ec0e980968b93a2ebe88bd89bf99b697 Author: Daniel Stone Date: Tue Nov 6 14:52:03 2007 +0000 DIX: XKB: Set xkbInfo to NULL as well as freeing it (bug # 10639) XkbRemoveResourceClient wants to access xkbInfo if it exists, so make sure we NULL it after freeing it. It doesn't make much sense to move the RemoveResourceClient call first, as there's not much point in notifying clients while we're shutting the server down anyway. Backported-to-NX-by: Ulrich Sibiller --- nx-X11/programs/Xserver/dix/devices.c | 1 + 1 file changed, 1 insertion(+) (limited to 'nx-X11/programs/Xserver') diff --git a/nx-X11/programs/Xserver/dix/devices.c b/nx-X11/programs/Xserver/dix/devices.c index d649a8657..427169222 100644 --- a/nx-X11/programs/Xserver/dix/devices.c +++ b/nx-X11/programs/Xserver/dix/devices.c @@ -210,6 +210,7 @@ CloseDevice(register DeviceIntPtr dev) if (dev->key->xkbInfo) XkbFreeInfo(dev->key->xkbInfo); #endif + dev->key->xkbInfo = NULL; free(dev->key->curKeySyms.map); free(dev->key->modifierKeyMap); free(dev->key); -- cgit v1.2.3