diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-14 07:29:59 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-14 07:29:59 (GMT) |
commit | eee6c9db0590a4087098a7a7d85dd139bfda6d0f (patch) | |
tree | c272e64143c9b6b9e87c09c27871e55787cc1d58 | |
parent | c9fe293db7a52a34954db92d2bdc5454d4de3897 (diff) | |
parent | 7cfd623dc5324f153717a00faa7c3e080811bcbb (diff) | |
download | tk-eee6c9db0590a4087098a7a7d85dd139bfda6d0f.zip tk-eee6c9db0590a4087098a7a7d85dd139bfda6d0f.tar.gz tk-eee6c9db0590a4087098a7a7d85dd139bfda6d0f.tar.bz2 |
Fix [dacd18294b]: Undefined behavior in tkTextBTree.c (out of bounds access in array)
-rw-r--r-- | generic/tkText.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/generic/tkText.h b/generic/tkText.h index 0ccced2..e29a8ac 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -172,9 +172,12 @@ typedef struct TkTextSegment { Tcl_Size size; /* Size of this segment (# of bytes of index * space it occupies). */ union { - char chars[4]; /* Characters that make up character info. - * Actual length varies to hold as many - * characters as needed.*/ + /* The TKFLEXARRAY macro - unfortunately - doesn't work inside a union. */ +#if defined(__GNUC__) && (__GNUC__ > 2) + char chars[0]; /* Characters that make up character info. */ +#else /* Actual length varies to hold as many */ + char chars[1]; /* characters as needed. See [dacd18294b] */ +#endif TkTextToggle toggle; /* Information about tag toggle. */ TkTextMark mark; /* Information about mark. */ TkTextEmbWindow ew; /* Information about embedded window. */ |