aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-03-01 11:59:55 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-03-01 11:59:55 +0100
commitd156ce5ab6afa3bc67189f4985e1517d5aca52b3 (patch)
tree76679bd38f93ec2b069e20db90d4e602d368d0ec
parenta70e36c8114c0358258e8c3964b9d897884e265e (diff)
parente7a50079ed90bd9f9f292d3f40ed3905c034a4cc (diff)
downloadnx-libs-d156ce5ab6afa3bc67189f4985e1517d5aca52b3.tar.gz
nx-libs-d156ce5ab6afa3bc67189f4985e1517d5aca52b3.tar.bz2
nx-libs-d156ce5ab6afa3bc67189f4985e1517d5aca52b3.zip
Merge branch 'uli42-pr/xfixes_memset' into 3.6.x
Attributes GH PR #788: https://github.com/ArcticaProject/nx-libs/pull/788
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxcmds.c4
-rw-r--r--nx-X11/programs/Xserver/Xext/sync.c2
-rw-r--r--nx-X11/programs/Xserver/damageext/damageext.c10
-rw-r--r--nx-X11/programs/Xserver/dbe/dbe.c34
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/NXrender.c15
-rw-r--r--nx-X11/programs/Xserver/record/record.c35
-rw-r--r--nx-X11/programs/Xserver/render/render.c18
-rw-r--r--nx-X11/programs/Xserver/xfixes/cursor.c24
-rw-r--r--nx-X11/programs/Xserver/xfixes/region.c4
-rw-r--r--nx-X11/programs/Xserver/xfixes/xfixes.c11
10 files changed, 85 insertions, 72 deletions
diff --git a/nx-X11/programs/Xserver/GL/glx/glxcmds.c b/nx-X11/programs/Xserver/GL/glx/glxcmds.c
index 353697727..16ecdb1e0 100644
--- a/nx-X11/programs/Xserver/GL/glx/glxcmds.c
+++ b/nx-X11/programs/Xserver/GL/glx/glxcmds.c
@@ -2084,7 +2084,7 @@ int __glXQueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
reply.n = n;
/* 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)
return BadAlloc;
memcpy(buf, ptr, n);
@@ -2141,7 +2141,7 @@ int __glXQueryServerString(__GLXclientState *cl, GLbyte *pc)
reply.length = length;
reply.n = n;
- if ((buf = (char *) malloc(length << 2)) == NULL) {
+ if ((buf = calloc(length, 4)) == NULL) {
return BadAlloc;
}
memcpy(buf, ptr, n);
diff --git a/nx-X11/programs/Xserver/Xext/sync.c b/nx-X11/programs/Xserver/Xext/sync.c
index bc7cb404a..00f30e484 100644
--- a/nx-X11/programs/Xserver/Xext/sync.c
+++ b/nx-X11/programs/Xserver/Xext/sync.c
@@ -590,7 +590,7 @@ SyncSendCounterNotifyEvents(client, ppAwait, num_events)
if (client->clientGone)
return;
pev = pEvents = (xSyncCounterNotifyEvent *)
- malloc(num_events * sizeof(xSyncCounterNotifyEvent));
+ calloc(num_events, sizeof(xSyncCounterNotifyEvent));
if (!pEvents)
return;
UpdateCurrentTime();
diff --git a/nx-X11/programs/Xserver/damageext/damageext.c b/nx-X11/programs/Xserver/damageext/damageext.c
index b9d99a53c..56677e320 100644
--- a/nx-X11/programs/Xserver/damageext/damageext.c
+++ b/nx-X11/programs/Xserver/damageext/damageext.c
@@ -132,15 +132,15 @@ static int
ProcDamageQueryVersion(ClientPtr client)
{
DamageClientPtr pDamageClient = GetDamageClient (client);
- xDamageQueryVersionReply rep;
+ xDamageQueryVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0
+ };
REQUEST(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) {
rep.majorVersion = stuff->majorVersion;
rep.minorVersion = stuff->minorVersion;
diff --git a/nx-X11/programs/Xserver/dbe/dbe.c b/nx-X11/programs/Xserver/dbe/dbe.c
index 588dd0582..446571311 100644
--- a/nx-X11/programs/Xserver/dbe/dbe.c
+++ b/nx-X11/programs/Xserver/dbe/dbe.c
@@ -312,16 +312,16 @@ static int
ProcDbeGetVersion(ClientPtr client)
{
/* 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);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = DBE_MAJOR_VERSION;
- rep.minorVersion = DBE_MINOR_VERSION;
-
if (client->swapped)
{
swaps(&rep.sequenceNumber);
@@ -946,10 +946,12 @@ ProcDbeGetVisualInfo(ClientPtr client)
length += pScrVisInfo[i].count * sizeof(xDbeVisInfo);
}
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = length >> 2;
- rep.m = count;
+ rep = (xDbeGetVisualInfoReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = length >> 2,
+ .m = count
+ };
if (client->swapped)
{
@@ -1041,7 +1043,11 @@ static int
ProcDbeGetBackBufferAttributes(ClientPtr client)
{
REQUEST(xDbeGetBackBufferAttributesReq);
- xDbeGetBackBufferAttributesReply rep;
+ xDbeGetBackBufferAttributesReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0
+ };
DbeWindowPrivPtr pDbeWindowPriv;
REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq);
@@ -1056,10 +1062,6 @@ ProcDbeGetBackBufferAttributes(ClientPtr client)
rep.attributes = pDbeWindowPriv->pWindow->drawable.id;
}
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
-
if (client->swapped)
{
swaps(&rep.sequenceNumber);
diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c
index ce4ea9d5f..fd9c0be82 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c
@@ -135,7 +135,14 @@ static int
ProcRenderQueryVersion (ClientPtr client)
{
RenderClientPtr pRenderClient = GetRenderClient (client);
- xRenderQueryVersionReply rep;
+ xRenderQueryVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .majorVersion = nxagentRenderVersionMajor,
+ .minorVersion = nxagentRenderVersionMinor
+ };
+
REQUEST(xRenderQueryVersionReq);
REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
@@ -143,12 +150,6 @@ ProcRenderQueryVersion (ClientPtr client)
pRenderClient->major_version = stuff->majorVersion;
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) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
diff --git a/nx-X11/programs/Xserver/record/record.c b/nx-X11/programs/Xserver/record/record.c
index c18b96e46..31803a289 100644
--- a/nx-X11/programs/Xserver/record/record.c
+++ b/nx-X11/programs/Xserver/record/record.c
@@ -1949,14 +1949,16 @@ static int
ProcRecordQueryVersion(ClientPtr client)
{
/* 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);
- 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)
{
swaps(&rep.sequenceNumber);
@@ -2287,6 +2289,7 @@ ProcRecordGetContext(ClientPtr client)
GetContextRangeInfoPtr pri;
int i;
int err;
+ CARD32 nClients, length;
REQUEST_SIZE_MATCH(xRecordGetContextReq);
VERIFY_CONTEXT(pContext, stuff->context, client);
@@ -2359,24 +2362,28 @@ ProcRecordGetContext(ClientPtr client)
/* calculate number of clients and reply length */
- rep.nClients = 0;
- rep.length = 0;
+ nClients = 0;
+ length = 0;
for (pRCAP = pContext->pListOfRCAP, pri = pRangeInfo;
pRCAP;
pRCAP = pRCAP->pNextRCAP, pri++)
{
- rep.nClients += pRCAP->numClients;
- rep.length += pRCAP->numClients *
+ nClients += pRCAP->numClients;
+ length += pRCAP->numClients *
( (sizeof(xRecordClientInfo) >> 2) +
pri->nRanges * (sizeof(xRecordRange) >> 2));
}
/* write the reply header */
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.enabled = pContext->pRecordingClient != NULL;
- rep.elementHeader = pContext->elemHeaders;
+ rep = (xRecordGetContextReply) {
+ .type = X_Reply,
+ .enabled = pContext->pRecordingClient != NULL,
+ .sequenceNumber = client->sequence,
+ .length = length,
+ .elementHeader = pContext->elemHeaders,
+ .nClients = nClients
+ };
if(client->swapped)
{
swaps(&rep.sequenceNumber);
diff --git a/nx-X11/programs/Xserver/render/render.c b/nx-X11/programs/Xserver/render/render.c
index 3c1cbe53c..e4d8a3f76 100644
--- a/nx-X11/programs/Xserver/render/render.c
+++ b/nx-X11/programs/Xserver/render/render.c
@@ -274,7 +274,13 @@ static int
ProcRenderQueryVersion (ClientPtr 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);
@@ -283,12 +289,6 @@ ProcRenderQueryVersion (ClientPtr client)
pRenderClient->major_version = stuff->majorVersion;
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) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -580,7 +580,7 @@ ProcRenderQueryPictIndexValues (ClientPtr client)
num = pFormat->index.nvalues;
rlength = (sizeof (xRenderQueryPictIndexValuesReply) +
num * sizeof(xIndexValue));
- reply = (xRenderQueryPictIndexValuesReply *) malloc (rlength);
+ reply = (xRenderQueryPictIndexValuesReply *) calloc (1, rlength);
if (!reply)
return BadAlloc;
@@ -1746,7 +1746,7 @@ ProcRenderQueryFilters (ClientPtr client)
}
len = ((nnames + 1) >> 1) + ((nbytesName + 3) >> 2);
total_bytes = sizeof (xRenderQueryFiltersReply) + (len << 2);
- reply = (xRenderQueryFiltersReply *) malloc (total_bytes);
+ reply = (xRenderQueryFiltersReply *) calloc (1, total_bytes);
if (!reply)
return BadAlloc;
aliases = (INT16 *) (reply + 1);
diff --git a/nx-X11/programs/Xserver/xfixes/cursor.c b/nx-X11/programs/Xserver/xfixes/cursor.c
index 152bda500..fc4c1d803 100644
--- a/nx-X11/programs/Xserver/xfixes/cursor.c
+++ b/nx-X11/programs/Xserver/xfixes/cursor.c
@@ -201,7 +201,7 @@ XFixesSelectCursorInput (ClientPtr pClient,
}
if (!e)
{
- e = (CursorEventPtr) malloc (sizeof (CursorEventRec));
+ e = (CursorEventPtr) calloc (1, sizeof (CursorEventRec));
if (!e)
return BadAlloc;
@@ -364,8 +364,8 @@ ProcXFixesGetCursorImage (ClientPtr client)
width = pCursor->bits->width;
height = pCursor->bits->height;
npixels = width * height;
- rep = malloc (sizeof (xXFixesGetCursorImageReply) +
- npixels * sizeof (CARD32));
+ rep = calloc (sizeof (xXFixesGetCursorImageReply) +
+ npixels * sizeof (CARD32), 1);
if (!rep)
return BadAlloc;
@@ -456,11 +456,13 @@ ProcXFixesGetCursorName (ClientPtr client)
str = "";
len = strlen (str);
- reply.type = X_Reply;
- reply.length = (len + 3) >> 2;
- reply.sequenceNumber = client->sequence;
- reply.atom = pCursor->name;
- reply.nbytes = len;
+ reply = (xXFixesGetCursorNameReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = (len + 3) >> 2,
+ .atom = pCursor->name,
+ .nbytes = len
+ };
if (client->swapped) {
swaps(&reply.sequenceNumber);
swapl(&reply.length);
@@ -508,8 +510,8 @@ ProcXFixesGetCursorImageAndName (ClientPtr client)
name = pCursor->name ? NameForAtom (pCursor->name) : "";
nbytes = strlen (name);
nbytesRound = (nbytes + 3) & ~3;
- rep = malloc (sizeof (xXFixesGetCursorImageAndNameReply) +
- npixels * sizeof (CARD32) + nbytesRound);
+ rep = calloc (sizeof (xXFixesGetCursorImageAndNameReply) +
+ npixels * sizeof (CARD32) + nbytesRound, 1);
if (!rep)
return BadAlloc;
@@ -757,7 +759,7 @@ createCursorHideCount (ClientPtr pClient, ScreenPtr pScreen)
CursorScreenPtr cs = GetCursorScreen(pScreen);
CursorHideCountPtr pChc;
- pChc = (CursorHideCountPtr) malloc(sizeof(CursorHideCountRec));
+ pChc = (CursorHideCountPtr) calloc(1, sizeof(CursorHideCountRec));
if (pChc == NULL) {
return BadAlloc;
}
diff --git a/nx-X11/programs/Xserver/xfixes/region.c b/nx-X11/programs/Xserver/xfixes/region.c
index ba8c62835..849df6869 100644
--- a/nx-X11/programs/Xserver/xfixes/region.c
+++ b/nx-X11/programs/Xserver/xfixes/region.c
@@ -570,8 +570,8 @@ ProcXFixesFetchRegion (ClientPtr client)
pBox = RegionRects (pRegion);
nBox = RegionNumRects (pRegion);
- reply = malloc (sizeof (xXFixesFetchRegionReply) +
- nBox * sizeof (xRectangle));
+ reply = calloc (sizeof (xXFixesFetchRegionReply) +
+ nBox * sizeof (xRectangle), 1);
if (!reply)
return BadAlloc;
reply->type = X_Reply;
diff --git a/nx-X11/programs/Xserver/xfixes/xfixes.c b/nx-X11/programs/Xserver/xfixes/xfixes.c
index fadaf73b2..7fe94a99c 100644
--- a/nx-X11/programs/Xserver/xfixes/xfixes.c
+++ b/nx-X11/programs/Xserver/xfixes/xfixes.c
@@ -56,14 +56,15 @@ static int
ProcXFixesQueryVersion(ClientPtr client)
{
XFixesClientPtr pXFixesClient = GetXFixesClient (client);
- xXFixesQueryVersionReply rep;
+ xXFixesQueryVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0
+ };
REQUEST(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) {
rep.majorVersion = stuff->majorVersion;
rep.minorVersion = stuff->minorVersion;