Fixed memory leak with colormap allocation.

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@447 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
Peter Åstrand 2003-08-27 08:21:53 +00:00
parent 24d1be278a
commit d8670cb4de

10
xwin.c
View File

@ -103,7 +103,7 @@ PixelColour;
/* colour maps */ /* colour maps */
BOOL owncolmap = False; BOOL owncolmap = False;
static Colormap xcolmap; static Colormap xcolmap;
static uint32 *colmap; static uint32 *colmap = NULL;
#define TRANSLATE(col) ( g_server_bpp != 8 ? translate_colour(col) : owncolmap ? col : translate_colour(colmap[col]) ) #define TRANSLATE(col) ( g_server_bpp != 8 ? translate_colour(col) : owncolmap ? col : translate_colour(colmap[col]) )
#define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col)); #define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col));
@ -600,7 +600,8 @@ ui_init(void)
if (ownbackstore) if (ownbackstore)
{ {
backstore = backstore =
XCreatePixmap(display, RootWindowOfScreen(screen), g_width, g_height, depth); XCreatePixmap(display, RootWindowOfScreen(screen), g_width, g_height,
depth);
/* clear to prevent rubbish being exposed at startup */ /* clear to prevent rubbish being exposed at startup */
XSetForeground(display, gc, BlackPixelOfScreen(screen)); XSetForeground(display, gc, BlackPixelOfScreen(screen));
@ -1347,7 +1348,12 @@ void
ui_set_colourmap(HCOLOURMAP map) ui_set_colourmap(HCOLOURMAP map)
{ {
if (!owncolmap) if (!owncolmap)
{
if (colmap)
xfree(colmap);
colmap = (uint32 *) map; colmap = (uint32 *) map;
}
else else
XSetWindowColormap(display, wnd, (Colormap) map); XSetWindowColormap(display, wnd, (Colormap) map);
} }