diff options
Diffstat (limited to 'xorg-server/glx/glxcmds.c')
-rw-r--r-- | xorg-server/glx/glxcmds.c | 129 |
1 files changed, 67 insertions, 62 deletions
diff --git a/xorg-server/glx/glxcmds.c b/xorg-server/glx/glxcmds.c index 2fc3f4cc8..c39a3f461 100644 --- a/xorg-server/glx/glxcmds.c +++ b/xorg-server/glx/glxcmds.c @@ -31,6 +31,7 @@ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif +#include "glheader.h" #include <string.h> #include <assert.h> @@ -46,6 +47,8 @@ #include "indirect_table.h" #include "indirect_util.h" +#include "glfunctions.h" + static char GLXServerVendorName[] = "SGI"; _X_HIDDEN int @@ -502,7 +505,7 @@ __glXGetDrawable(__GLXcontext * glxc, GLXDrawable drawId, ClientPtr client, return NULL; } - if (pDraw->pScreen != glxc->pGlxScreen->pScreen) { + if (!glxc || pDraw->pScreen != glxc->pGlxScreen->pScreen) { client->errorValue = pDraw->pScreen->myNum; *error = BadMatch; return NULL; @@ -515,9 +518,11 @@ __glXGetDrawable(__GLXcontext * glxc, GLXDrawable drawId, ClientPtr client, pDraw, drawId, GLX_DRAWABLE_WINDOW, drawId, glxc->config); - if (!pGlxDraw) { - *error = BadAlloc; - return NULL; + if (!pGlxDraw) + { + client->errorValue = drawId; + *error = BadMatch; + return NULL; } /* since we are creating the drawablePrivate, drawId should be new */ @@ -659,12 +664,12 @@ DoMakeCurrent(__GLXclientState * cl, StopUsingContext(prevglxc); - reply = (xGLXMakeCurrentReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 0, - .contextTag = 0 - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = 0; + reply.contextTag = 0; + if (glxc) { StartUsingContext(cl, glxc); @@ -730,12 +735,12 @@ __glXDisp_IsDirect(__GLXclientState * cl, GLbyte * pc) if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err)) return err; - reply = (xGLXIsDirectReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 0, - .isDirect = glxc->isDirect - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = 0; + reply.isDirect = glxc->isDirect; + if (client->swapped) { __glXSwapIsDirectReply(client, &reply); @@ -767,13 +772,13 @@ __glXDisp_QueryVersion(__GLXclientState * cl, GLbyte * pc) ** client if it wants to work with older clients; however, in this ** implementation the server just returns its version number. */ - reply = (xGLXQueryVersionReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 0, - .majorVersion = glxMajorVersion, - .minorVersion = glxMinorVersion - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = 0; + reply.majorVersion = glxMajorVersion; + reply.minorVersion = glxMinorVersion; + if (client->swapped) { __glXSwapQueryVersionReply(client, &reply); @@ -947,14 +952,14 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc) if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; - reply = (xGLXGetVisualConfigsReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = (pGlxScreen->numVisuals * + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = (pGlxScreen->numVisuals * __GLX_SIZE_CARD32 * GLX_VIS_CONFIG_TOTAL) >> 2, - .numVisuals = pGlxScreen->numVisuals, - .numProps = GLX_VIS_CONFIG_TOTAL - }; + reply.numVisuals = pGlxScreen->numVisuals; + reply.numProps = GLX_VIS_CONFIG_TOTAL; + if (client->swapped) { __GLX_SWAP_SHORT(&reply.sequenceNumber); @@ -1062,13 +1067,13 @@ DoGetFBConfigs(__GLXclientState * cl, unsigned screen) if (!validGlxScreen(cl->client, screen, &pGlxScreen, &err)) return err; - reply = (xGLXGetFBConfigsReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = __GLX_FBCONFIG_ATTRIBS_LENGTH * pGlxScreen->numFBConfigs, - .numFBConfigs = pGlxScreen->numFBConfigs, - .numAttribs = __GLX_TOTAL_FBCONFIG_ATTRIBS - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = __GLX_FBCONFIG_ATTRIBS_LENGTH * pGlxScreen->numFBConfigs; + reply.numFBConfigs = pGlxScreen->numFBConfigs; + reply.numAttribs = __GLX_TOTAL_FBCONFIG_ATTRIBS; + if (client->swapped) { __GLX_SWAP_SHORT(&reply.sequenceNumber); @@ -1705,7 +1710,7 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId) ClientPtr client = cl->client; __GLXcontext *ctx; xGLXQueryContextInfoEXTReply reply; - int nProps = 3; + #define nProps 3 int sendBuf[nProps * 2]; int nReplyBytes; int err; @@ -1713,12 +1718,12 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId) if (!validGlxContext(cl->client, gcId, DixReadAccess, &ctx, &err)) return err; - reply = (xGLXQueryContextInfoEXTReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = nProps << 1, - .n = nProps - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = nProps << 1; + reply.n = nProps; + nReplyBytes = reply.length << 2; sendBuf[0] = GLX_SHARE_CONTEXT_EXT; @@ -1940,12 +1945,12 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId) numAttribs++; } - reply = (xGLXGetDrawableAttributesReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = numAttribs << 1, - .numAttribs = numAttribs - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = numAttribs << 1; + reply.numAttribs = numAttribs; + if (client->swapped) { __glXSwapGetDrawableAttributesReply(client, &reply, attributes); @@ -2370,12 +2375,12 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc) n = strlen(pGlxScreen->GLXextensions) + 1; length = __GLX_PAD(n) >> 2; - reply = (xGLXQueryExtensionsStringReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = length, - .n = n - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = length; + reply.n = n; + /* Allocate buffer to make sure it's a multiple of 4 bytes big. */ buf = calloc(length, 4); @@ -2433,12 +2438,12 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc) n = strlen(ptr) + 1; length = __GLX_PAD(n) >> 2; - reply = (xGLXQueryServerStringReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = length, - .n = n - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = length; + reply.n = n; + buf = calloc(length, 4); if (buf == NULL) { |