summaryrefslogtreecommitdiffstats
path: root/generic/tkText.h
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-06-14 07:29:59 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-06-14 07:29:59 (GMT)
commiteee6c9db0590a4087098a7a7d85dd139bfda6d0f (patch)
treec272e64143c9b6b9e87c09c27871e55787cc1d58 /generic/tkText.h
parentc9fe293db7a52a34954db92d2bdc5454d4de3897 (diff)
parent7cfd623dc5324f153717a00faa7c3e080811bcbb (diff)
downloadtk-eee6c9db0590a4087098a7a7d85dd139bfda6d0f.zip
tk-eee6c9db0590a4087098a7a7d85dd139bfda6d0f.tar.gz
tk-eee6c9db0590a4087098a7a7d85dd139bfda6d0f.tar.bz2
Fix [dacd18294b]: Undefined behavior in tkTextBTree.c (out of bounds access in array)
Diffstat (limited to 'generic/tkText.h')
-rw-r--r--generic/tkText.h9
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. */