Fix color leak

* src/xterm.c (x_alloc_nearest_color_1): Don't allocate colors
multiple times when searching for a closest match.
This commit is contained in:
Po Lu 2022-03-07 19:53:52 +08:00
parent 8b66adfe06
commit f2b58db280

View file

@ -3882,12 +3882,8 @@ x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color)
temp.red = cells[x].red;
temp.green = cells[x].green;
temp.blue = cells[x].blue;
status = XAllocColor (dpy, cmap, &temp);
if (status)
{
nearest = x;
nearest_delta = trial_delta;
}
nearest = x;
nearest_delta = trial_delta;
}
}
color->red = cells[nearest].red;