Overview
| Artifact ID: | f7b0109757367b752e8e58cca28b3a736a388b6c |
|---|---|
| Ticket: | 758110ffffffffffffffffffffffffffffffffff
patch for 'dict info {}' |
| User & Date: | hgiese on 2003-06-20 19:07:49 |
Changes
- assignee changed to: "dkf"
- cmimetype changed to: "text/plain"
- 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 - foundin changed to: "None"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "hgiese"
- subsystem changed to: "15. Dict Object"
- title changed to: "patch for 'dict info {}'"
- type changed to: "Patch"