Here's a patch for the underlying cause. Since Gabriel's patch
prevents further damage it's now mostly useful as a record of what went
wrong and as an optimisation.From e7d36cb8f078c046b17510d7fc7bf7993d537858 Mon Sep 17 00:00:00 2001
From: Iain Patterson <[email protected]>
Date: Wed, 19 Jun 2013 17:35:09 +0100
Subject: [PATCH] Don't crash when SwitchPanelImages is None.
The whole changeImage() function in switchpanel.c is a no-op if
wPreferences.swtileImage is set to None because the panel isn't actually
drawn in that case. As a consequence there are no images to change.
As well as being logically incorrect the existing code causes a segfault
if the user has the SwitchPanelImages preference set to None because
changeImage() would attempt to access the icons and images arrays which
are only initialised in wInitSwitchPanel() when swtileImage has a value.
Bug report and diagnosis by Juan Giordana, Gabriel Vlasiu and Christophe
Curis.
---
src/switchpanel.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/switchpanel.c b/src/switchpanel.c
index 62ced77..f616bfa 100644
--- a/src/switchpanel.c
+++ b/src/switchpanel.c
@@ -112,11 +112,19 @@ static Bool sameWindowClass(WWindow *wwin, WWindow
*curwin)
static void changeImage(WSwitchPanel *panel, int idecks, int selected, Bool
dim, Bool force)
{
- WMFrame *icon = WMGetFromArray(panel->icons, idecks);
- RImage *image = WMGetFromArray(panel->images, idecks);
- char flags = (char) (uintptr_t) WMGetFromArray(panel->flags, idecks);
+ WMFrame *icon = NULL;
+ RImage *image = NULL;
+ char flags = 0;
char desired = 0;
+ /* This whole function is a no-op if we aren't drawing the panel */
+ if (!wPreferences.swtileImage)
+ return;
+
+ icon = WMGetFromArray(panel->icons, idecks);
+ image = WMGetFromArray(panel->images, idecks);
+ flags = (char) (uintptr_t) WMGetFromArray(panel->flags, idecks);
+
if (selected)
desired |= ICON_SELECTED;
if (dim)
--
1.8.1.4