--- dbe.c.orig 2008-05-12 00:25:06.533959000 -0600 +++ dbe.c 2008-05-12 00:26:53.162930000 -0600 @@ -299,14 +299,6 @@ return(BadAlloc); bzero(pDbeWindowPriv, sizeof(DbeWindowPrivRec)); - /* Make the window priv a DBE window priv resource. */ - if (!AddResource(stuff->buffer, dbeWindowPrivResType, - (pointer)pDbeWindowPriv)) - { - xfree(pDbeWindowPriv); - return(BadAlloc); - } - /* Fill out window priv information. */ pDbeWindowPriv->pWindow = pWin; pDbeWindowPriv->width = pWin->drawable.width; @@ -409,13 +401,28 @@ status = (*pDbeScreenPriv->AllocBackBufferName)(pWin, stuff->buffer, stuff->swapAction); - if ((status != Success) && (pDbeWindowPriv->nBufferIDs == 0)) + if (status == Success) { - /* The DDX buffer allocation routine failed for the first buffer of - * this window. - */ - xfree(pDbeWindowPriv); - return(status); + if (pDbeWindowPriv->nBufferIDs == 0) + { + /* Make the window priv a DBE window priv resource. */ + if (!AddResource(stuff->buffer, dbeWindowPrivResType, + (pointer)pDbeWindowPriv)) + { + xfree(pDbeWindowPriv); + pWin->devPrivates[dbeWindowPrivIndex].ptr = (pointer)NULL; + return(BadAlloc); + } + } + } + else + { + if (pDbeWindowPriv->nBufferIDs == 0) + { + xfree(pDbeWindowPriv); + pWin->devPrivates[dbeWindowPrivIndex].ptr = (pointer)NULL; + return(status); + } } /* Increment the number of buffers (XIDs) associated with this window. */