Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: a021dcee10ec653d5abb3759851243fd942f33c0c4ea39bcf19ffe5b3c7f2bfd
Ticket: 96551aca555c70e4e2157c534c8fdb11acf784e9
Avoid pointer arithmetic with NULL in FOREACH_STRUCT()
User & Date: chrstphrchvz on 2023-04-22 07:23:48
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    Not aware exactly what Tcl code triggers this, but it appears 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);
      */
    &nbsp;
     #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>
    &nbsp;
     /*
      * Convenience macros for iterating through hash tables. FOREACH_HASH_DECLS
    </pre></blockquote>
    
    <pre>
    </pre>
    
  5. foundin changed to: "core-8-branch"
  6. is_private changed to: "0"
  7. login: "chrstphrchvz"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "6133eb3026f9b10aa9b7b48da92ae2834fc225b0"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "chrstphrchvz"
  14. subsystem changed to: "35. TclOO Package"
  15. title changed to:
    Avoid pointer arithmetic with NULL in FOREACH_STRUCT()
    
  16. type changed to: "Patch"