Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f7b0109757367b752e8e58cca28b3a736a388b6c
Ticket: 758110ffffffffffffffffffffffffffffffffff
patch for 'dict info {}'
User & Date: hgiese on 2003-06-20 19:07:49
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Hello out there,
    the command
        dict info ""
    leads to a crash in my Borland generated Tcl 8.5a0 (on
    Win98).
    
    Here is what happens on my machine:
    - The first time around in DictInfoCmd the TclObj in
    question is not of
      type dictionary and so it gets converted via a call
    to SetDictFromAny.
    - Then the variable 'Dict *dict' is properly
    initialised. Inspecting it
      I see that its 'table' element has its element
    'numEntries' set to '0'
      - reasonable.
    - But then within Tcl_HashStats one calculates
        average += (tmp+1.0)*(tmp/tablePtr->numEntries)/2.0;
      with tablePtr->numEntries being '0' -> BOOM.
    
    I would suggest the following change in function
    "Tcl_HashStats" (file
    tclHash.c):
    
    Put the line
            average +=
    (tmp+1.0)*(tmp/tablePtr->numEntries)/2.0;
    into a conditional like
            /*
             * On machines not supporting "automatic NAN
    handling" or such, we
             * really should test for the denominator == 0
             */
            if ( tablePtr->numEntries )
                average +=
    (tmp+1.0)*(tmp/tablePtr->numEntries)/2.0;
    
    This will return a value of 0.0 for the average - which
    is maybe not
    exactly right but a reasonable value for an empty
    dictionary.
    
    Best regards
    Helmut Giese
    
    
  4. foundin changed to: "None"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "hgiese"
  9. subsystem changed to: "15. Dict Object"
  10. title changed to: "patch for 'dict info {}'"
  11. type changed to: "Patch"