From 4402a80630912a462bfa7fc9d085a9ca8dd7452b Mon Sep 17 00:00:00 2001 From: Lauri Kasanen Date: Wed, 27 May 2015 15:54:39 +0300 Subject: [PATCH] Partial backport of ddb8d8945d1f44d16 for valgrind cleanliness --- Xext/bigreq.c | 1 + Xext/shape.c | 1 + Xext/shm.c | 1 + Xext/sync.c | 1 + dix/devices.c | 2 ++ dix/dispatch.c | 11 +++++++++-- dix/dixfonts.c | 2 ++ dix/events.c | 1 + 8 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Xext/bigreq.c b/Xext/bigreq.c index 6c93052..8059641 100644 --- a/Xext/bigreq.c +++ b/Xext/bigreq.c @@ -88,6 +88,7 @@ ClientPtr client; return BadRequest; REQUEST_SIZE_MATCH(xBigReqEnableReq); client->big_requests = TRUE; + memset(&rep, 0, sizeof(xBigReqEnableReply)); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; diff --git a/Xext/shape.c b/Xext/shape.c index 19445bc..5e6f01c 100644 --- a/Xext/shape.c +++ b/Xext/shape.c @@ -303,6 +303,7 @@ ClientPtr client; xShapeQueryVersionReply rep; REQUEST_SIZE_MATCH(xShapeQueryVersionReq); + memset(&rep, 0, sizeof(xShapeQueryVersionReply)); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; diff --git a/Xext/shm.c b/Xext/shm.c index 98e5102..957fcf3 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -324,6 +324,7 @@ ClientPtr client; REQUEST_SIZE_MATCH(xShmQueryVersionReq); + memset(&rep, 0, sizeof(xShmQueryVersionReply)); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; diff --git a/Xext/sync.c b/Xext/sync.c index b647a25..460cc5e 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -1319,6 +1319,7 @@ ClientPtr client; REQUEST_SIZE_MATCH(xSyncInitializeReq); + memset(&rep, 0, sizeof(xSyncInitializeReply)); rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.majorVersion = SYNC_MAJOR_VERSION; diff --git a/dix/devices.c b/dix/devices.c index ca62f49..64fe652 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -807,6 +807,7 @@ ProcGetModifierMapping(ClientPtr client) KeyClassPtr keyc = inputInfo.keyboard->key; REQUEST_SIZE_MATCH(xReq); + memset(&rep, 0, sizeof(xGetModifierMappingReply)); rep.type = X_Reply; rep.numKeyPerModifier = keyc->maxKeysPerModifier; rep.sequenceNumber = client->sequence; @@ -920,6 +921,7 @@ ProcGetKeyboardMapping(ClientPtr client) return BadValue; } + memset(&rep, 0, sizeof(xGetKeyboardMappingReply)); rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.keySymsPerKeyCode = curKeySyms->mapWidth; diff --git a/dix/dispatch.c b/dix/dispatch.c index bb8dac5..de15948 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -555,6 +555,7 @@ ProcGetWindowAttributes(register ClientPtr client) SecurityReadAccess); if (!pWin) return (BadWindow); + memset(&wa, 0, sizeof(xGetWindowAttributesReply)); GetWindowAttributes(pWin, client, &wa); WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa); return (client->noClientException); @@ -817,6 +818,7 @@ ProcGetGeometry(register ClientPtr client) int status; + memset(&rep, 0, sizeof(xGetGeometryReply)); if ((status = GetGeometry(client, &rep)) != Success) return status; @@ -842,6 +844,7 @@ ProcQueryTree(register ClientPtr client) SecurityReadAccess); if (!pWin) return (BadWindow); + memset(&reply, 0, sizeof(xQueryTreeReply)); reply.type = X_Reply; reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; reply.sequenceNumber = client->sequence; @@ -896,6 +899,7 @@ ProcInternAtom(register ClientPtr client) if (atom != BAD_RESOURCE) { xInternAtomReply reply = {0}; + memset(&reply, 0, sizeof(xInternAtomReply)); reply.type = X_Reply; reply.length = 0; reply.sequenceNumber = client->sequence; @@ -921,6 +925,7 @@ ProcGetAtomName(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); if ((str = NameForAtom(stuff->id))) { len = strlen(str); + memset(&reply, 0, sizeof(xGetAtomNameReply)); reply.type = X_Reply; reply.length = (len + 3) >> 2; reply.sequenceNumber = client->sequence; @@ -1194,6 +1199,7 @@ ProcTranslateCoords(register ClientPtr client) SecurityReadAccess); if (!pDst) return (BadWindow); + memset(&rep, 0, sizeof(xTranslateCoordsReply)); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -1332,7 +1338,7 @@ ProcQueryFont(register ClientPtr client) rlength = sizeof(xQueryFontReply) + FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) + nprotoxcistructs * sizeof(xCharInfo); - reply = (xQueryFontReply *) ALLOCATE_LOCAL(rlength); + reply = (xQueryFontReply *) calloc(1, rlength); if (!reply) { return (BadAlloc); } @@ -1343,7 +1349,7 @@ ProcQueryFont(register ClientPtr client) QueryFont(pFont, reply, nprotoxcistructs); WriteReplyToClient(client, rlength, reply); - DEALLOCATE_LOCAL(reply); + free(reply); return (client->noClientException); } } @@ -2104,6 +2110,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, return (BadValue); } SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, SecurityReadAccess); + memset(&xgi, 0, sizeof(xGetImageReply)); if (pDraw->type == DRAWABLE_WINDOW) { if ( /* check for being viewable */ !((WindowPtr) pDraw)->realized || diff --git a/dix/dixfonts.c b/dix/dixfonts.c index 7157833..667ff21 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -782,6 +782,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) for (i = 0; i < nnames; i++) stringLens += (names->length[i] <= 255) ? names->length[i] : 0; + memset(&reply, 0, sizeof(xListFontsReply)); reply.type = X_Reply; reply.length = (stringLens + nnames + 3) >> 2; reply.nFonts = nnames; @@ -1028,6 +1029,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) err = AllocError; goto bail; } + memset(reply + c->length, 0, length - c->length); c->reply = reply; c->length = length; } diff --git a/dix/events.c b/dix/events.c index 0caa3df..0412f93 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2879,6 +2879,7 @@ ProcQueryPointer(ClientPtr client) return BadWindow; if (mouse->valuator->motionHintWindow) MaybeStopHint(mouse, client); + memset(&rep, 0, sizeof(xQueryPointerReply)); rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.mask = mouse->button->state | inputInfo.keyboard->key->state;