diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-08 20:43:52 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-08 20:43:52 (GMT) |
commit | 19d012df44dac9aaf5faa9b3beca5a6396ea21a8 (patch) | |
tree | 3806205b7a13d85e2d11a5cea2d6f9665f569b9a /xlib | |
parent | 19349f662acefdded4ad020f003c6945d9f9da23 (diff) | |
download | tk-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.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -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 |