diff options
author | Brian <brian@yutani.localnet.net> | 2006-09-23 10:38:10 -0600 |
---|---|---|
committer | Brian <brian@yutani.localnet.net> | 2006-09-23 10:38:10 -0600 |
commit | f7c1d942416db8d0d4c5a21f5ece1ccacb926b69 (patch) | |
tree | c2596c1aae95765bb168d017fc16b716b77001a7 /hw/dmx/dmxcmap.c | |
parent | 945b7c63946f5257d0f9b0dcf2f8f4882fb2c6f8 (diff) |
Check for visual==NULL in dmxBECreateColormap() before calling XCreateColormap()
to prevent potential segfault.
Diffstat (limited to 'hw/dmx/dmxcmap.c')
-rw-r--r-- | hw/dmx/dmxcmap.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/hw/dmx/dmxcmap.c b/hw/dmx/dmxcmap.c index b4279e7ce..9a9781f53 100644 --- a/hw/dmx/dmxcmap.c +++ b/hw/dmx/dmxcmap.c @@ -40,6 +40,7 @@ #endif #include "dmx.h" +#include "dmxlog.h" #include "dmxsync.h" #include "dmxcmap.h" #include "dmxvisual.h" @@ -83,12 +84,18 @@ Bool dmxBECreateColormap(ColormapPtr pColormap) VisualPtr pVisual = pColormap->pVisual; Visual *visual = dmxLookupVisual(pScreen, pVisual); - pCmapPriv->cmap = XCreateColormap(dmxScreen->beDisplay, - dmxScreen->scrnWin, - visual, - (pVisual->class & DynamicClass ? - AllocAll : AllocNone)); - return (pCmapPriv->cmap != 0); + if (visual) { + pCmapPriv->cmap = XCreateColormap(dmxScreen->beDisplay, + dmxScreen->scrnWin, + visual, + (pVisual->class & DynamicClass ? + AllocAll : AllocNone)); + return (pCmapPriv->cmap != 0); + } + else { + dmxLog(dmxWarning, "dmxBECreateColormap: No visual found\n"); + return 0; + } } /** Create colormap on back-end server associated with \a pColormap's |