From 0e615addeecefdcb56a2623a7a6fe871bb2d4c05 Mon Sep 17 00:00:00 2001 From: marc_culler Date: Sat, 12 Sep 2020 22:10:22 +0000 Subject: Apply patch from Christopher Chavez to address UBSan warnings about alignment in ttkMacOSXTheme.c --- macosx/ttkMacOSXTheme.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index e999fc2..316d52e 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -2144,10 +2144,13 @@ static void TrackElementDraw( Tcl_GetDoubleFromObj(NULL, elem->valueObj, &value); factor = RangeToFactor(to); + // HIThemeTrackDrawInfo uses 2-byte alignment; assign to separate + // bounds variable to avoid UBSan (-fsanitize=alignment) complaint. + CGRect bounds = BoxToRect(d, b); HIThemeTrackDrawInfo info = { .version = 0, .kind = data->kind, - .bounds = BoxToRect(d, b), + .bounds = bounds, .min = from * factor, .max = to * factor, .value = value * factor, @@ -2282,13 +2285,16 @@ static void PbarElementDraw( Tcl_GetIntFromObj(NULL, pbar->phaseObj, &phase); factor = RangeToFactor(maximum); + // HIThemeTrackDrawInfo uses 2-byte alignment; assign to separate + // bounds variable to avoid UBSan (-fsanitize=alignment) complaint. + CGRect bounds = BoxToRect(d, b); HIThemeTrackDrawInfo info = { .version = 0, .kind = (!strcmp("indeterminate", Tcl_GetString(pbar->modeObj)) && value) ? kThemeIndeterminateBar : kThemeProgressBar, - .bounds = BoxToRect(d, b), + .bounds = bounds, .min = 0, .max = maximum * factor, .value = value * factor, -- cgit v0.12