Unverified Commit d156ce5a authored by Mike Gabriel's avatar Mike Gabriel

Merge branch 'uli42-pr/xfixes_memset' into 3.6.x

parents a70e36c8 e7a50079
...@@ -2084,7 +2084,7 @@ int __glXQueryExtensionsString(__GLXclientState *cl, GLbyte *pc) ...@@ -2084,7 +2084,7 @@ int __glXQueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
reply.n = n; reply.n = n;
/* Allocate buffer to make sure it's a multiple of 4 bytes big.*/ /* Allocate buffer to make sure it's a multiple of 4 bytes big.*/
buf = (char *) malloc(length << 2); buf = calloc(length, 4);
if (buf == NULL) if (buf == NULL)
return BadAlloc; return BadAlloc;
memcpy(buf, ptr, n); memcpy(buf, ptr, n);
...@@ -2141,7 +2141,7 @@ int __glXQueryServerString(__GLXclientState *cl, GLbyte *pc) ...@@ -2141,7 +2141,7 @@ int __glXQueryServerString(__GLXclientState *cl, GLbyte *pc)
reply.length = length; reply.length = length;
reply.n = n; reply.n = n;
if ((buf = (char *) malloc(length << 2)) == NULL) { if ((buf = calloc(length, 4)) == NULL) {
return BadAlloc; return BadAlloc;
} }
memcpy(buf, ptr, n); memcpy(buf, ptr, n);
......
...@@ -590,7 +590,7 @@ SyncSendCounterNotifyEvents(client, ppAwait, num_events) ...@@ -590,7 +590,7 @@ SyncSendCounterNotifyEvents(client, ppAwait, num_events)
if (client->clientGone) if (client->clientGone)
return; return;
pev = pEvents = (xSyncCounterNotifyEvent *) pev = pEvents = (xSyncCounterNotifyEvent *)
malloc(num_events * sizeof(xSyncCounterNotifyEvent)); calloc(num_events, sizeof(xSyncCounterNotifyEvent));
if (!pEvents) if (!pEvents)
return; return;
UpdateCurrentTime(); UpdateCurrentTime();
......
...@@ -132,15 +132,15 @@ static int ...@@ -132,15 +132,15 @@ static int
ProcDamageQueryVersion(ClientPtr client) ProcDamageQueryVersion(ClientPtr client)
{ {
DamageClientPtr pDamageClient = GetDamageClient (client); DamageClientPtr pDamageClient = GetDamageClient (client);
xDamageQueryVersionReply rep; xDamageQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0
};
REQUEST(xDamageQueryVersionReq); REQUEST(xDamageQueryVersionReq);
REQUEST_SIZE_MATCH(xDamageQueryVersionReq); REQUEST_SIZE_MATCH(xDamageQueryVersionReq);
memset(&rep, 0, sizeof(xDamageQueryVersionReply));
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
if (stuff->majorVersion < SERVER_DAMAGE_MAJOR_VERSION) { if (stuff->majorVersion < SERVER_DAMAGE_MAJOR_VERSION) {
rep.majorVersion = stuff->majorVersion; rep.majorVersion = stuff->majorVersion;
rep.minorVersion = stuff->minorVersion; rep.minorVersion = stuff->minorVersion;
......
...@@ -312,16 +312,16 @@ static int ...@@ -312,16 +312,16 @@ static int
ProcDbeGetVersion(ClientPtr client) ProcDbeGetVersion(ClientPtr client)
{ {
/* REQUEST(xDbeGetVersionReq); */ /* REQUEST(xDbeGetVersionReq); */
xDbeGetVersionReply rep; xDbeGetVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = DBE_MAJOR_VERSION,
.minorVersion = DBE_MINOR_VERSION
};
REQUEST_SIZE_MATCH(xDbeGetVersionReq); REQUEST_SIZE_MATCH(xDbeGetVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = DBE_MAJOR_VERSION;
rep.minorVersion = DBE_MINOR_VERSION;
if (client->swapped) if (client->swapped)
{ {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber);
...@@ -946,10 +946,12 @@ ProcDbeGetVisualInfo(ClientPtr client) ...@@ -946,10 +946,12 @@ ProcDbeGetVisualInfo(ClientPtr client)
length += pScrVisInfo[i].count * sizeof(xDbeVisInfo); length += pScrVisInfo[i].count * sizeof(xDbeVisInfo);
} }
rep.type = X_Reply; rep = (xDbeGetVisualInfoReply) {
rep.sequenceNumber = client->sequence; .type = X_Reply,
rep.length = length >> 2; .sequenceNumber = client->sequence,
rep.m = count; .length = length >> 2,
.m = count
};
if (client->swapped) if (client->swapped)
{ {
...@@ -1041,7 +1043,11 @@ static int ...@@ -1041,7 +1043,11 @@ static int
ProcDbeGetBackBufferAttributes(ClientPtr client) ProcDbeGetBackBufferAttributes(ClientPtr client)
{ {
REQUEST(xDbeGetBackBufferAttributesReq); REQUEST(xDbeGetBackBufferAttributesReq);
xDbeGetBackBufferAttributesReply rep; xDbeGetBackBufferAttributesReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0
};
DbeWindowPrivPtr pDbeWindowPriv; DbeWindowPrivPtr pDbeWindowPriv;
REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq); REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq);
...@@ -1056,10 +1062,6 @@ ProcDbeGetBackBufferAttributes(ClientPtr client) ...@@ -1056,10 +1062,6 @@ ProcDbeGetBackBufferAttributes(ClientPtr client)
rep.attributes = pDbeWindowPriv->pWindow->drawable.id; rep.attributes = pDbeWindowPriv->pWindow->drawable.id;
} }
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;
if (client->swapped) if (client->swapped)
{ {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber);
......
...@@ -135,7 +135,14 @@ static int ...@@ -135,7 +135,14 @@ static int
ProcRenderQueryVersion (ClientPtr client) ProcRenderQueryVersion (ClientPtr client)
{ {
RenderClientPtr pRenderClient = GetRenderClient (client); RenderClientPtr pRenderClient = GetRenderClient (client);
xRenderQueryVersionReply rep; xRenderQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = nxagentRenderVersionMajor,
.minorVersion = nxagentRenderVersionMinor
};
REQUEST(xRenderQueryVersionReq); REQUEST(xRenderQueryVersionReq);
REQUEST_SIZE_MATCH(xRenderQueryVersionReq); REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
...@@ -143,12 +150,6 @@ ProcRenderQueryVersion (ClientPtr client) ...@@ -143,12 +150,6 @@ ProcRenderQueryVersion (ClientPtr client)
pRenderClient->major_version = stuff->majorVersion; pRenderClient->major_version = stuff->majorVersion;
pRenderClient->minor_version = stuff->minorVersion; pRenderClient->minor_version = stuff->minorVersion;
memset(&rep, 0, sizeof(xRenderQueryVersionReply));
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = nxagentRenderVersionMajor;
rep.minorVersion = nxagentRenderVersionMinor;
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber);
swapl(&rep.length); swapl(&rep.length);
......
...@@ -1949,14 +1949,16 @@ static int ...@@ -1949,14 +1949,16 @@ static int
ProcRecordQueryVersion(ClientPtr client) ProcRecordQueryVersion(ClientPtr client)
{ {
/* REQUEST(xRecordQueryVersionReq); */ /* REQUEST(xRecordQueryVersionReq); */
xRecordQueryVersionReply rep; xRecordQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_RECORD_MAJOR_VERSION,
.minorVersion = SERVER_RECORD_MINOR_VERSION
};
REQUEST_SIZE_MATCH(xRecordQueryVersionReq); REQUEST_SIZE_MATCH(xRecordQueryVersionReq);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;
rep.majorVersion = SERVER_RECORD_MAJOR_VERSION;
rep.minorVersion = SERVER_RECORD_MINOR_VERSION;
if(client->swapped) if(client->swapped)
{ {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber);
...@@ -2287,6 +2289,7 @@ ProcRecordGetContext(ClientPtr client) ...@@ -2287,6 +2289,7 @@ ProcRecordGetContext(ClientPtr client)
GetContextRangeInfoPtr pri; GetContextRangeInfoPtr pri;
int i; int i;
int err; int err;
CARD32 nClients, length;
REQUEST_SIZE_MATCH(xRecordGetContextReq); REQUEST_SIZE_MATCH(xRecordGetContextReq);
VERIFY_CONTEXT(pContext, stuff->context, client); VERIFY_CONTEXT(pContext, stuff->context, client);
...@@ -2359,24 +2362,28 @@ ProcRecordGetContext(ClientPtr client) ...@@ -2359,24 +2362,28 @@ ProcRecordGetContext(ClientPtr client)
/* calculate number of clients and reply length */ /* calculate number of clients and reply length */
rep.nClients = 0; nClients = 0;
rep.length = 0; length = 0;
for (pRCAP = pContext->pListOfRCAP, pri = pRangeInfo; for (pRCAP = pContext->pListOfRCAP, pri = pRangeInfo;
pRCAP; pRCAP;
pRCAP = pRCAP->pNextRCAP, pri++) pRCAP = pRCAP->pNextRCAP, pri++)
{ {
rep.nClients += pRCAP->numClients; nClients += pRCAP->numClients;
rep.length += pRCAP->numClients * length += pRCAP->numClients *
( (sizeof(xRecordClientInfo) >> 2) + ( (sizeof(xRecordClientInfo) >> 2) +
pri->nRanges * (sizeof(xRecordRange) >> 2)); pri->nRanges * (sizeof(xRecordRange) >> 2));
} }
/* write the reply header */ /* write the reply header */
rep.type = X_Reply; rep = (xRecordGetContextReply) {
rep.sequenceNumber = client->sequence; .type = X_Reply,
rep.enabled = pContext->pRecordingClient != NULL; .enabled = pContext->pRecordingClient != NULL,
rep.elementHeader = pContext->elemHeaders; .sequenceNumber = client->sequence,
.length = length,
.elementHeader = pContext->elemHeaders,
.nClients = nClients
};
if(client->swapped) if(client->swapped)
{ {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber);
......
...@@ -274,7 +274,13 @@ static int ...@@ -274,7 +274,13 @@ static int
ProcRenderQueryVersion (ClientPtr client) ProcRenderQueryVersion (ClientPtr client)
{ {
RenderClientPtr pRenderClient = GetRenderClient (client); RenderClientPtr pRenderClient = GetRenderClient (client);
xRenderQueryVersionReply rep; xRenderQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_RENDER_MAJOR_VERSION,
.minorVersion = SERVER_RENDER_MINOR_VERSION
};
REQUEST(xRenderQueryVersionReq); REQUEST(xRenderQueryVersionReq);
...@@ -283,12 +289,6 @@ ProcRenderQueryVersion (ClientPtr client) ...@@ -283,12 +289,6 @@ ProcRenderQueryVersion (ClientPtr client)
pRenderClient->major_version = stuff->majorVersion; pRenderClient->major_version = stuff->majorVersion;
pRenderClient->minor_version = stuff->minorVersion; pRenderClient->minor_version = stuff->minorVersion;
memset(&rep, 0, sizeof(xRenderQueryVersionReply));
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = SERVER_RENDER_MAJOR_VERSION;
rep.minorVersion = SERVER_RENDER_MINOR_VERSION;
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber);
swapl(&rep.length); swapl(&rep.length);
...@@ -580,7 +580,7 @@ ProcRenderQueryPictIndexValues (ClientPtr client) ...@@ -580,7 +580,7 @@ ProcRenderQueryPictIndexValues (ClientPtr client)
num = pFormat->index.nvalues; num = pFormat->index.nvalues;
rlength = (sizeof (xRenderQueryPictIndexValuesReply) + rlength = (sizeof (xRenderQueryPictIndexValuesReply) +
num * sizeof(xIndexValue)); num * sizeof(xIndexValue));
reply = (xRenderQueryPictIndexValuesReply *) malloc (rlength); reply = (xRenderQueryPictIndexValuesReply *) calloc (1, rlength);
if (!reply) if (!reply)
return BadAlloc; return BadAlloc;
...@@ -1746,7 +1746,7 @@ ProcRenderQueryFilters (ClientPtr client) ...@@ -1746,7 +1746,7 @@ ProcRenderQueryFilters (ClientPtr client)
} }
len = ((nnames + 1) >> 1) + ((nbytesName + 3) >> 2); len = ((nnames + 1) >> 1) + ((nbytesName + 3) >> 2);
total_bytes = sizeof (xRenderQueryFiltersReply) + (len << 2); total_bytes = sizeof (xRenderQueryFiltersReply) + (len << 2);
reply = (xRenderQueryFiltersReply *) malloc (total_bytes); reply = (xRenderQueryFiltersReply *) calloc (1, total_bytes);
if (!reply) if (!reply)
return BadAlloc; return BadAlloc;
aliases = (INT16 *) (reply + 1); aliases = (INT16 *) (reply + 1);
......
...@@ -201,7 +201,7 @@ XFixesSelectCursorInput (ClientPtr pClient, ...@@ -201,7 +201,7 @@ XFixesSelectCursorInput (ClientPtr pClient,
} }
if (!e) if (!e)
{ {
e = (CursorEventPtr) malloc (sizeof (CursorEventRec)); e = (CursorEventPtr) calloc (1, sizeof (CursorEventRec));
if (!e) if (!e)
return BadAlloc; return BadAlloc;
...@@ -364,8 +364,8 @@ ProcXFixesGetCursorImage (ClientPtr client) ...@@ -364,8 +364,8 @@ ProcXFixesGetCursorImage (ClientPtr client)
width = pCursor->bits->width; width = pCursor->bits->width;
height = pCursor->bits->height; height = pCursor->bits->height;
npixels = width * height; npixels = width * height;
rep = malloc (sizeof (xXFixesGetCursorImageReply) + rep = calloc (sizeof (xXFixesGetCursorImageReply) +
npixels * sizeof (CARD32)); npixels * sizeof (CARD32), 1);
if (!rep) if (!rep)
return BadAlloc; return BadAlloc;
...@@ -456,11 +456,13 @@ ProcXFixesGetCursorName (ClientPtr client) ...@@ -456,11 +456,13 @@ ProcXFixesGetCursorName (ClientPtr client)
str = ""; str = "";
len = strlen (str); len = strlen (str);
reply.type = X_Reply; reply = (xXFixesGetCursorNameReply) {
reply.length = (len + 3) >> 2; .type = X_Reply,
reply.sequenceNumber = client->sequence; .sequenceNumber = client->sequence,
reply.atom = pCursor->name; .length = (len + 3) >> 2,
reply.nbytes = len; .atom = pCursor->name,
.nbytes = len
};
if (client->swapped) { if (client->swapped) {
swaps(&reply.sequenceNumber); swaps(&reply.sequenceNumber);
swapl(&reply.length); swapl(&reply.length);
...@@ -508,8 +510,8 @@ ProcXFixesGetCursorImageAndName (ClientPtr client) ...@@ -508,8 +510,8 @@ ProcXFixesGetCursorImageAndName (ClientPtr client)
name = pCursor->name ? NameForAtom (pCursor->name) : ""; name = pCursor->name ? NameForAtom (pCursor->name) : "";
nbytes = strlen (name); nbytes = strlen (name);
nbytesRound = (nbytes + 3) & ~3; nbytesRound = (nbytes + 3) & ~3;
rep = malloc (sizeof (xXFixesGetCursorImageAndNameReply) + rep = calloc (sizeof (xXFixesGetCursorImageAndNameReply) +
npixels * sizeof (CARD32) + nbytesRound); npixels * sizeof (CARD32) + nbytesRound, 1);
if (!rep) if (!rep)
return BadAlloc; return BadAlloc;
...@@ -757,7 +759,7 @@ createCursorHideCount (ClientPtr pClient, ScreenPtr pScreen) ...@@ -757,7 +759,7 @@ createCursorHideCount (ClientPtr pClient, ScreenPtr pScreen)
CursorScreenPtr cs = GetCursorScreen(pScreen); CursorScreenPtr cs = GetCursorScreen(pScreen);
CursorHideCountPtr pChc; CursorHideCountPtr pChc;
pChc = (CursorHideCountPtr) malloc(sizeof(CursorHideCountRec)); pChc = (CursorHideCountPtr) calloc(1, sizeof(CursorHideCountRec));
if (pChc == NULL) { if (pChc == NULL) {
return BadAlloc; return BadAlloc;
} }
......
...@@ -570,8 +570,8 @@ ProcXFixesFetchRegion (ClientPtr client) ...@@ -570,8 +570,8 @@ ProcXFixesFetchRegion (ClientPtr client)
pBox = RegionRects (pRegion); pBox = RegionRects (pRegion);
nBox = RegionNumRects (pRegion); nBox = RegionNumRects (pRegion);
reply = malloc (sizeof (xXFixesFetchRegionReply) + reply = calloc (sizeof (xXFixesFetchRegionReply) +
nBox * sizeof (xRectangle)); nBox * sizeof (xRectangle), 1);
if (!reply) if (!reply)
return BadAlloc; return BadAlloc;
reply->type = X_Reply; reply->type = X_Reply;
......
...@@ -56,14 +56,15 @@ static int ...@@ -56,14 +56,15 @@ static int
ProcXFixesQueryVersion(ClientPtr client) ProcXFixesQueryVersion(ClientPtr client)
{ {
XFixesClientPtr pXFixesClient = GetXFixesClient (client); XFixesClientPtr pXFixesClient = GetXFixesClient (client);
xXFixesQueryVersionReply rep; xXFixesQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0
};
REQUEST(xXFixesQueryVersionReq); REQUEST(xXFixesQueryVersionReq);
REQUEST_SIZE_MATCH(xXFixesQueryVersionReq); REQUEST_SIZE_MATCH(xXFixesQueryVersionReq);
memset(&rep, 0, sizeof(xXFixesQueryVersionReply));
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
if (stuff->majorVersion < SERVER_XFIXES_MAJOR_VERSION) { if (stuff->majorVersion < SERVER_XFIXES_MAJOR_VERSION) {
rep.majorVersion = stuff->majorVersion; rep.majorVersion = stuff->majorVersion;
rep.minorVersion = stuff->minorVersion; rep.minorVersion = stuff->minorVersion;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment