Overview
| Artifact ID: | bf1787bfdb2d30fdce8249eaf4f81f67977fa0ef17a0b782aa4ef93770dd961a |
|---|---|
| Ticket: | 96551aca555c70e4e2157c534c8fdb11acf784e9
Avoid pointer arithmetic with NULL in FOREACH_STRUCT() |
| User & Date: | chrstphrchvz on 2023-04-22 07:32:11 |
Changes
- comment changed to:
Not aware exactly what Tcl code triggers this, but this <tt>-fsanitize=pointer-overflow</tt> error is emitted at the beginning of output from <tt>tcltest</tt> during <tt>make test</tt>: <blockquote><pre> <b>generic/tclOOMethod.c:1108:2: <span style="color:firebrick">runtime error:</span> applying zero offset to null pointer</b> </pre></blockquote> Something like the following is needed (<tt>var</tt> should also be parenthesized to avoid surprises): <blockquote><pre> --- generic/tclOOInt.h.orig +++ generic/tclOOInt.h @@ -594,7 +594,7 @@ MODULE_SCOPE void TclOOSetupVariableResolver(Tcl_Namespace *nsPtr); */ #define FOREACH_STRUCT(var,ary) \ <span style="color:firebrick">- for(i=0 ; var=&((ary).list[i]), i<(ary).num; i++)</span> <span style="color:green">+ for(i=0 ; (var)=((ary).list ? &((ary).list[i]) : NULL), i<(ary).num; i++)</span> /* * Convenience macros for iterating through hash tables. FOREACH_HASH_DECLS </pre></blockquote> <pre> </pre>
- login: "chrstphrchvz"
- mimetype: "text/plain"