Overview
| Artifact ID: | f39f7d121843a9795c6162936b237f77faea2aaf |
|---|---|
| Ticket: | 491341ffffffffffffffffffffffffffffffffff
GetsObj: trunc/append confusion @EOF |
| User & Date: | dgp on 2001-12-10 22:31:37 |
Changes
- assignee changed to: "andreas_kupries"
- cmimetype changed to: "text/plain"
- comment changed to:
When Tcl_GetsObj(chan, obj) receives an obj that already has a non-empty string rep, the bytes read from chan are supposed to be appended to the existing string rep. It is incorrect to assume that obj->bytes is an empty string. Tcl_GetsObj() gets this right almost everywhere, but this part of the spec was forgotten in lines 3634-3644 of tclIO.c, where EOF handling takes place. Those lines only work if obj->bytes passed in is an empty string. Since [gets] always does pass in such an empty Tcl_Obj, this bug isn't visible at the script level, but it shows up regularly in the call at line 300 of tclMain.c. Lines 304-306 of tclMain.c even appear to be an awkward attempt to work around this bug, without ever identifying it as a bug. To demo the bug, create a file test.tcl with a single line: if 1 { Then at a shell prompt $ tclsh < test.tcl This will stick tclsh in an infinite loop. Attached is the simple patch that correctly tests for "no characters read @ EOF" when obj-> bytes is non-empty. - foundin changed to: "obsolete: 8.4a4"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "dgp"
- subsystem changed to: "25. Channel System"
- title changed to: "GetsObj: trunc/append confusion @EOF "
- type changed to: "Bug"