Re: [PATCH] randr: add swapped dispatch for RR[GS]etCrtcTransform

2008-11-27 Thread Keith Packard
On Wed, 2008-11-26 at 22:14 +0100, Julien Cristau wrote:

> +SwapLongs((CARD32 *)&stuff->transform, (sizeof xRenderTransform) >> 2);
> +swaps(&stuff->nbytesFilter);

Please try compiling patches before submitting them. Testing would be a
nice bonus too.

-- 
[EMAIL PROTECTED]


signature.asc
Description: This is a digitally signed message part
___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg

[PATCH] randr: add swapped dispatch for RR[GS]etCrtcTransform

2008-11-27 Thread Julien Cristau
Fix a memory leak in ProcRRGetCrtcTransform() while I'm at it.

Signed-off-by: Julien Cristau <[EMAIL PROTECTED]>
Cc: Keith Packard <[EMAIL PROTECTED]>
---
 randr/rrcrtc.c  |6 +++---
 randr/rrsdispatch.c |   29 ++---
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 5d270ce..90d93b5 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -1150,8 +1150,7 @@ transform_filter_encode (ClientPtr client, char *output,
 if (client->swapped) {
swaps (nbytesFilter, n);
swaps (nparamsFilter, n);
-   SwapLongs ((CARD32 *) (output + nbytes),
-  nparams * sizeof (xFixed));
+   SwapLongs ((CARD32 *) (output + nbytes), nparams);
 }
 nbytes += nparams * sizeof (xFixed);
 return nbytes;
@@ -1162,7 +1161,7 @@ transform_encode (ClientPtr client, xRenderTransform 
*wire, PictTransform *pict)
 {
 xRenderTransform_from_PictTransform (wire, pict);
 if (client->swapped)
-   SwapLongs ((CARD32 *) wire, sizeof (xRenderTransform));
+   SwapLongs ((CARD32 *) wire, sizeof (xRenderTransform) >> 2);
 }
 
 int
@@ -1214,5 +1213,6 @@ ProcRRGetCrtcTransform (ClientPtr client)
swapl (&reply->length, n);
 }
 WriteToClient (client, sizeof (xRRGetCrtcTransformReply) + nextra, (char 
*) reply);
+xfree(reply);
 return client->noClientException;
 }
diff --git a/randr/rrsdispatch.c b/randr/rrsdispatch.c
index 66a0e16..90216be 100644
--- a/randr/rrsdispatch.c
+++ b/randr/rrsdispatch.c
@@ -367,21 +367,36 @@ SProcRRSetCrtcGamma (ClientPtr client)
 static int
 SProcRRSetCrtcTransform (ClientPtr client)
 {
+int n, nparams;
+char *filter;
+CARD32 *params;
 REQUEST(xRRSetCrtcTransformReq);
-
-REQUEST_SIZE_MATCH(xRRSetCrtcTransformReq);
-(void) stuff;
-return BadImplementation; 
+
+REQUEST_AT_LEAST_SIZE(xRRSetCrtcTransformReq);
+swaps(&stuff->length, n);
+swapl(&stuff->crtc, n);
+SwapLongs((CARD32 *)&stuff->transform, (sizeof xRenderTransform) >> 2);
+swaps(&stuff->nbytesFilter);
+filter = (char *)(stuff + 1);
+params = (CARD32 *) (filter + ((stuff->nbytesFilter + 3) & ~3));
+nparams = ((CARD32 *) stuff + client->req_len) - params;
+if (nparams < 0)
+   return BadLength;
+
+SwapLongs(params, nparams);
+return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRGetCrtcTransform (ClientPtr client)
 {
+int n;
 REQUEST(xRRGetCrtcTransformReq);
-
+
 REQUEST_SIZE_MATCH(xRRGetCrtcTransformReq);
-(void) stuff;
-return BadImplementation; 
+swaps(&stuff->length, n);
+swapl(&stuff->crtc, n);
+return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
-- 
1.5.6.5

___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg