aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-10 20:51:43 +0100
committerDavid Robillard <d@drobilla.net>2020-11-10 20:51:43 +0100
commitc7213092415732272aa5ccd4547940bf9fe4c7b5 (patch)
tree11322cfa0081e8d2a17931d893066827fe5d2201 /src
parent7dde3e3ad6bfed5eb6aeeb27833f5f1a9f83de33 (diff)
downloadpugl-c7213092415732272aa5ccd4547940bf9fe4c7b5.tar.gz
pugl-c7213092415732272aa5ccd4547940bf9fe4c7b5.tar.bz2
pugl-c7213092415732272aa5ccd4547940bf9fe4c7b5.zip
Fix asan errors on X11
Fun with union punning. The different sizes mean that stuff on the stack could be copied to the destination event. I don't think this would cause a concrete issue (the contents of the event past the expose are irrelevant) but asan quite reasonably has a problem with it.
Diffstat (limited to 'src')
-rw-r--r--src/x11.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/x11.c b/src/x11.c
index b462dd0..93ed599 100644
--- a/src/x11.c
+++ b/src/x11.c
@@ -875,20 +875,18 @@ puglWaitForEvent(PuglView* view)
#endif
static void
-mergeExposeEvents(PuglEvent* dst, const PuglEvent* src)
+mergeExposeEvents(PuglEventExpose* dst, const PuglEventExpose* src)
{
if (!dst->type) {
*dst = *src;
} else {
- const double max_x = MAX(dst->expose.x + dst->expose.width,
- src->expose.x + src->expose.width);
- const double max_y = MAX(dst->expose.y + dst->expose.height,
- src->expose.y + src->expose.height);
-
- dst->expose.x = MIN(dst->expose.x, src->expose.x);
- dst->expose.y = MIN(dst->expose.y, src->expose.y);
- dst->expose.width = max_x - dst->expose.x;
- dst->expose.height = max_y - dst->expose.y;
+ const double max_x = MAX(dst->x + dst->width, src->x + src->width);
+ const double max_y = MAX(dst->y + dst->height, src->y + src->height);
+
+ dst->x = MIN(dst->x, src->x);
+ dst->y = MIN(dst->y, src->y);
+ dst->width = max_x - dst->x;
+ dst->height = max_y - dst->y;
}
}
@@ -1063,7 +1061,7 @@ puglDispatchX11Events(PuglWorld* world)
if (event.type == PUGL_EXPOSE) {
// Expand expose event to be dispatched after loop
- mergeExposeEvents(&view->impl->pendingExpose, &event);
+ mergeExposeEvents(&view->impl->pendingExpose.expose, &event.expose);
} else if (event.type == PUGL_CONFIGURE) {
// Expand configure event to be dispatched after loop
view->impl->pendingConfigure = event;
@@ -1153,7 +1151,7 @@ puglPostRedisplayRect(PuglView* view, PuglRect rect)
if (view->world->impl->dispatchingEvents) {
// Currently dispatching events, add/expand expose for the loop end
- mergeExposeEvents(&view->impl->pendingExpose, (const PuglEvent*)&event);
+ mergeExposeEvents(&view->impl->pendingExpose.expose, &event);
} else if (view->visible) {
// Not dispatching events, send an X expose so we wake up next time
return puglSendEvent(view, (const PuglEvent*)&event);