summaryrefslogtreecommitdiffstats
path: root/xlib
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-09-08 20:43:52 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-09-08 20:43:52 (GMT)
commit19d012df44dac9aaf5faa9b3beca5a6396ea21a8 (patch)
tree3806205b7a13d85e2d11a5cea2d6f9665f569b9a /xlib
parent19349f662acefdded4ad020f003c6945d9f9da23 (diff)
downloadtk-19d012df44dac9aaf5faa9b3beca5a6396ea21a8.zip
tk-19d012df44dac9aaf5faa9b3beca5a6396ea21a8.tar.gz
tk-19d012df44dac9aaf5faa9b3beca5a6396ea21a8.tar.bz2
Fix [420feb3850]: Aqua: UBSan warns for misaligned TkpGCCache access.
Just define the memory layout we want (XGCValuesWithCache) and let the compiler do the calculations.
Diffstat (limited to 'xlib')
-rw-r--r--xlib/xgc.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/xlib/xgc.c b/xlib/xgc.c
index b145395..c0dbe84 100644
--- a/xlib/xgc.c
+++ b/xlib/xgc.c
@@ -16,7 +16,6 @@
#if !defined(MAC_OSX_TK)
# include <X11/Xlib.h>
-# define gcCacheSize 0
# define TkpInitGCCache(gc)
# define TkpFreeGCCache(gc)
# define TkpGetGCCache(gc)
@@ -26,11 +25,19 @@
# include <X11/X.h>
# define Cursor XCursor
# define Region XRegion
-# define gcCacheSize sizeof(TkpGCCache)
#endif
#undef TkSetRegion
+#define MAX_DASH_LIST_SIZE 10
+typedef struct {
+ XGCValues gc;
+ char dash[MAX_DASH_LIST_SIZE];
+#ifdef MAC_OSX_TK
+ TkpGCCache cache;
+#endif
+} XGCValuesWithCache;
+
/*
*----------------------------------------------------------------------
*
@@ -113,9 +120,7 @@ XCreateGC(
* initialization.
*/
-#define MAX_DASH_LIST_SIZE 10
-
- gp = (GC)ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize);
+ gp = (GC)ckalloc(sizeof(XGCValuesWithCache));
if (!gp) {
return NULL;
}
@@ -178,8 +183,7 @@ XCreateGC(
TkpGCCache*
TkpGetGCCache(GC gc) {
- return (gc ? (TkpGCCache*)(((char*) gc) + sizeof(XGCValues) +
- MAX_DASH_LIST_SIZE) : NULL);
+ return (gc ? &((XGCValuesWithCache *)gc)->cache : NULL);
}
#endif