summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas James Alexander Thurman <tthurman@src.gnome.org>2006-07-22 01:45:21 +0000
committerThomas James Alexander Thurman <tthurman@src.gnome.org>2006-07-22 01:45:21 +0000
commit5e85bf72104667613e701e6ce75e1dc0501dbdc7 (patch)
treedd846211404dc795ecf1e23131358ca29bc3b2f1
parent85f9c499fb3067f68aacd5e78b7793d21d5a1abc (diff)
downloadmetacity-5e85bf72104667613e701e6ce75e1dc0501dbdc7.tar.gz
Avoid a case where a struct's fields might be updated after it was freed.
* ui.[ch] (filter_func): Avoid a case where a struct's fields might be updated after it was freed. #348067.
-rw-r--r--ChangeLog5
-rw-r--r--src/ui.c15
2 files changed, 14 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 2dda0b4a..c8dc8929 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-07-21 Thomas Thurman <thomas@thurman.org.uk>
+
+ * ui.[ch] (filter_func): Avoid a case where a struct's
+ fields might be updated after it was freed. #348067.
+
2006-07-10 Elijah Newren <newren gmail com>
* configure.in: post-release version bump to 2.15.13
diff --git a/src/ui.c b/src/ui.c
index 19cbe9cf..cc067e3f 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -70,26 +70,29 @@ struct _EventFunc
int last_event_serial;
};
+static EventFunc *ef = NULL;
+
static GdkFilterReturn
filter_func (GdkXEvent *xevent,
GdkEvent *event,
gpointer data)
{
- EventFunc *ef;
-
- ef = data;
+ g_return_if_fail (ef != NULL);
if ((* ef->func) (xevent, ef->data))
return GDK_FILTER_REMOVE;
else
{
- ef->last_event_serial = ((XEvent*)xevent)->xany.serial;
+ /* ef would be NULL here if we removed the filter function
+ * in response to the event.
+ */
+ if (ef != NULL)
+ ef->last_event_serial = ((XEvent*)xevent)->xany.serial;
+
return GDK_FILTER_CONTINUE;
}
}
-static EventFunc *ef = NULL;
-
void
meta_ui_add_event_func (Display *xdisplay,
MetaEventFunc func,