[PATCH v2 09/29] ProcRRListOutputProperties: skip atom walk if the list is empty
Alan Coopersmith
alan.coopersmith at oracle.com
Wed Jul 4 15:37:23 PDT 2012
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 at oracle.com>
---
randr/rrproperty.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index e8f0578..b0a1cf9 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);
--
1.7.9.2
More information about the xorg-devel
mailing list