diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-11 12:31:48 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-11 12:31:48 (GMT) |
commit | 7f62b768876fc8b0779d10ae3fcba1fc7aeaba04 (patch) | |
tree | cc67956829bcf5ad5af0e714d5184b80475d25ce /generic/tclInt.h | |
parent | 0715d88019e40aa514b3b2d3ba691ab7d0a96eb2 (diff) | |
download | tcl-7f62b768876fc8b0779d10ae3fcba1fc7aeaba04.zip tcl-7f62b768876fc8b0779d10ae3fcba1fc7aeaba04.tar.gz tcl-7f62b768876fc8b0779d10ae3fcba1fc7aeaba04.tar.bz2 |
Fix [https://core.tcl-lang.org/tk/tktview?name=3bc0f44ef3|3bc0f44ef3]: UBSan complains about body.chars[] usage.
(Yes, I know, this one is for Tk, but Tcl was using the same construct too ....)
Diffstat (limited to 'generic/tclInt.h')
-rw-r--r-- | generic/tclInt.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h index 317ae1f..e145925 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -877,6 +877,12 @@ typedef struct VarInHash { *---------------------------------------------------------------- */ +#if defined(__GNUC__) && (__GNUC__ > 2) +# define TCLFLEXARRAY 0 +#else +# define TCLFLEXARRAY 1 +#endif + /* * Forward declaration to prevent an error when the forward reference to * Command is encountered in the Proc and ImportRef types declared below. @@ -920,7 +926,7 @@ typedef struct CompiledLocal { * is marked by a unique ClientData tag during * compilation, and that same tag is used to * find the variable at runtime. */ - char name[1]; /* Name of the local variable starts here. If + char name[TCLFLEXARRAY]; /* Name of the local variable starts here. If * the name is NULL, this will just be '\0'. * The actual size of this field will be large * enough to hold the name. MUST BE THE LAST @@ -1254,7 +1260,7 @@ typedef struct CFWordBC { typedef struct ContLineLoc { int num; /* Number of entries in loc, not counting the * final -1 marker entry. */ - int loc[1]; /* Table of locations, as character offsets. + int loc[TCLFLEXARRAY];/* Table of locations, as character offsets. * The table is allocated as part of the * structure, extending behind the nominal end * of the structure. An entry containing the |