summaryrefslogtreecommitdiff
path: root/src/add_window.c
diff options
context:
space:
mode:
authorEgbert Eich <eich@freedesktop.org>2011-05-19 11:08:21 +0200
committerEgbert Eich <eich@freedesktop.org>2012-11-30 07:09:07 -0500
commit07ed63f865f6fef4c14711063534b73eb33e0cdb (patch)
treeff254c2742b482e801543e6022e8068da1946243 /src/add_window.c
parentb62e91790d1f07f729d4221c878a0847ff14ad82 (diff)
Fix SEGV if CreateColormapWindow() returns NULL.
twm can segfault when it cannot collect attribute information on a window that has been destroyed before it got a chance to collect it's attributes. twm seems to assume that it is always able to collect this information and disregards the error if the function that attempts to collect it fails and CreateColormapWindow() returns NULL. If this happens correct number_cmap_windows to prevent a SEGV later on due to an incorrect setting. Signed-off-by: Egbert Eich <eich@freedesktop.org>
Diffstat (limited to 'src/add_window.c')
-rw-r--r--src/add_window.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/add_window.c b/src/add_window.c
index 8cf23c5..72aa0aa 100644
--- a/src/add_window.c
+++ b/src/add_window.c
@@ -1535,10 +1535,12 @@ FetchWmColormapWindows (TwmWindow *tmp)
cwins = (ColormapWindow **) malloc(sizeof(ColormapWindow *));
if (XFindContext(dpy, tmp->w, ColormapContext, (caddr_t *)&cwins[0]) ==
- XCNOENT)
+ XCNOENT) {
cwins[0] = CreateColormapWindow(tmp->w,
(Bool) tmp->cmaps.number_cwins == 0, False);
- else
+ if (cwins[0] == NULL)
+ number_cmap_windows = 0;
+ } else
cwins[0]->refcnt++;
}