diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-11 08:36:16 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-11 08:36:16 (GMT) |
commit | db31b9f1cedb54fbdc52442ea1c21bf06c556b68 (patch) | |
tree | 18ebe6081d8f7060398ae7faf268b4006e4f45ae /generic | |
parent | ae738cdf44ed05a923f20b3b9bb16c1edeaf6c8b (diff) | |
parent | b6336ef4ba80fceda0d210096a47706833f5850f (diff) | |
download | tk-db31b9f1cedb54fbdc52442ea1c21bf06c556b68.zip tk-db31b9f1cedb54fbdc52442ea1c21bf06c556b68.tar.gz tk-db31b9f1cedb54fbdc52442ea1c21bf06c556b68.tar.bz2 |
Fix [3bc0f44ef3]: UBSan complains about body.chars[] usage
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkFont.c | 2 | ||||
-rw-r--r-- | generic/tkInt.h | 5 | ||||
-rw-r--r-- | generic/tkPointer.c | 2 | ||||
-rw-r--r-- | generic/tkSelect.c | 2 | ||||
-rw-r--r-- | generic/tkText.h | 4 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 2 |
6 files changed, 11 insertions, 6 deletions
diff --git a/generic/tkFont.c b/generic/tkFont.c index ab431a0..3aed702 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -96,7 +96,7 @@ typedef struct TextLayout { * layout. */ int numChunks; /* Number of chunks actually used in following * array. */ - LayoutChunk chunks[1]; /* Array of chunks. The actual size will be + LayoutChunk chunks[TKFLEXARRAY];/* Array of chunks. The actual size will be * maxChunks. THIS FIELD MUST BE THE LAST IN * THE STRUCTURE. */ } TextLayout; diff --git a/generic/tkInt.h b/generic/tkInt.h index f4bb23f..9f22b99 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -84,6 +84,11 @@ # endif #endif +#if defined(__GNUC__) && (__GNUC__ > 2) +# define TKFLEXARRAY 0 +#else +# define TKFLEXARRAY 1 +#endif #ifndef Tcl_GetParent # define Tcl_GetParent Tcl_GetMaster diff --git a/generic/tkPointer.c b/generic/tkPointer.c index c17367a..cc67401 100644 --- a/generic/tkPointer.c +++ b/generic/tkPointer.c @@ -26,7 +26,7 @@ typedef struct { TkWindow *grabWinPtr; /* Window that defines the top of the grab * tree in a global grab. */ - int lastState; /* Last known state flags. */ + unsigned lastState; /* Last known state flags. */ XPoint lastPos; /* Last reported mouse position. */ TkWindow *lastWinPtr; /* Last reported mouse window. */ TkWindow *restrictWinPtr; /* Window to which all mouse events will be diff --git a/generic/tkSelect.c b/generic/tkSelect.c index 91f0836..9584be4 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -28,7 +28,7 @@ typedef struct { * chunk. */ char buffer[4]; /* A buffer to hold part of a UTF character * that is split across chunks. */ - char command[1]; /* Command to invoke. Actual space is + char command[TKFLEXARRAY]; /* Command to invoke. Actual space is * allocated as large as necessary. This must * be the last entry in the structure. */ } CommandInfo; diff --git a/generic/tkText.h b/generic/tkText.h index a8a17da..9a9495a 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -168,7 +168,7 @@ typedef struct TkTextSegment { int size; /* Size of this segment (# of bytes of index * space it occupies). */ union { - char chars[2]; /* Characters that make up character info. + char chars[TKFLEXARRAY]; /* Characters that make up character info. * Actual length varies to hold as many * characters as needed.*/ TkTextToggle toggle; /* Information about tag toggle. */ @@ -489,7 +489,7 @@ typedef struct TkTextTabArray { double tabIncrement; /* The accurate fractional pixel increment * between interpolated tabs we have to create * when we exceed numTabs. */ - TkTextTab tabs[1]; /* Array of tabs. The actual size will be + TkTextTab tabs[TKFLEXARRAY];/* Array of tabs. The actual size will be * numTabs. THIS FIELD MUST BE THE LAST IN THE * STRUCTURE. */ } TkTextTabArray; diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 6ab8508..0eae4a9 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -444,7 +444,7 @@ typedef struct TextDInfo { typedef struct CharInfo { int numBytes; /* Number of bytes to display. */ - char chars[1]; /* UTF characters to display. + char chars[TKFLEXARRAY]; /* UTF characters to display. * Allocated as large as necessary. THIS MUST BE THE LAST * FIELD IN THE STRUCTURE. */ } CharInfo; |