diff options
Diffstat (limited to 'xorg-server/glx/glxcmds.c')
-rwxr-xr-x[-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 f5f2babb8..4ac21a047 100644..100755 --- 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 @@ -511,7 +514,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; @@ -524,9 +527,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 */ @@ -668,12 +673,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); @@ -739,12 +744,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); @@ -776,13 +781,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); @@ -956,14 +961,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); @@ -1071,13 +1076,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); @@ -1714,7 +1719,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; @@ -1722,12 +1727,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; @@ -1960,12 +1965,12 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId) } } - reply = (xGLXGetDrawableAttributesReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = num << 1, - .numAttribs = num - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = num << 1; + reply.numAttribs = num; + if (client->swapped) { __glXSwapGetDrawableAttributesReply(client, &reply, attributes); @@ -2403,12 +2408,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); @@ -2466,12 +2471,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) { |