summaryrefslogtreecommitdiff
path: root/randr
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2012-07-09 19:12:42 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2012-07-09 19:58:29 -0700
commit2e739a8870d91fbac7f536ffa8f6d2cee0f66cec (patch)
tree2c428325bb9bc936060f5713b4c7ced14dc2dc0d /randr
parent15bc13c8d088e05f14c7262348e0066929c29251 (diff)
ProcRRListOutputProperties: skip atom walk if the list is empty
pAtoms is only allocated if numProps was non-zero, so move the walk through the property list to copy atoms to it inside the if (numProps) Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Keith Packard <keithp@keithp.com> Tested-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'randr')
-rw-r--r--randr/rrproperty.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index e8f057840..b0a1cf900 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -378,7 +378,7 @@ int
ProcRRListOutputProperties(ClientPtr client)
{
REQUEST(xRRListOutputPropertiesReq);
- Atom *pAtoms = NULL, *temppAtoms;
+ Atom *pAtoms = NULL;
xRRListOutputPropertiesReply rep;
int numProps = 0;
RROutputPtr output;
@@ -403,12 +403,14 @@ ProcRRListOutputProperties(ClientPtr client)
swapl(&rep.length);
swaps(&rep.nAtoms);
}
- temppAtoms = pAtoms;
- for (prop = output->properties; prop; prop = prop->next)
- *temppAtoms++ = prop->propertyName;
-
WriteToClient(client, sizeof(xRRListOutputPropertiesReply), &rep);
+
if (numProps) {
+ /* Copy property name atoms to reply buffer */
+ Atom *temppAtoms = pAtoms;
+ for (prop = output->properties; prop; prop = prop->next)
+ *temppAtoms++ = prop->propertyName;
+
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
free(pAtoms);