| Ticket UUID: | 821499 | ||
| Title: | Tcl_AppendToObj disobeys length | ||
| Type: | Bug | Created on: | 2003-10-10 21:38:50 |
| Submitter: | dgp | Assigned to: | jenglish |
| Subsystem: | 10. Objects | Severity: | |
| Priority: | 5 Medium | Last modified: | 2004-03-27 04:58:56 |
| Status: | Open | Closed by: | |
| Resolution: | None | Closed on: | |
| Version: | obsolete: 8.5a0 | ||
| Description: | ||||
#include "tcl.h"
int
main(int argc, char **argv)
{
Tcl_UniChar ch = 0;
Tcl_Obj *objPtr = Tcl_NewUnicodeObj(&ch,0);
Tcl_AppendToObj(objPtr,"\302\242",1);
ch = Tcl_GetUniChar(objPtr, 0);
if (ch != 0xC2) {
printf("BUG!\n");
if (ch == 0xA2) {
printf("Tcl_AppendToObj scanned > 1 byte\n");
}
}
}
Compile and run this test program for evidence
that Tcl_AppendToObj does not honor its
length argument. It will scan more than "length"
bytes if it thinks it's in the middle of a UTF-8 sequence.
| ||||
| User Comments: | ||||
jenglish added on 2003-10-11 07:14:29:
Logged In: YES user_id=68433 I think a case can be made that this is an illegal use of Tcl_AppendToObj(). It's not clear from the documentation whether Tcl_AppendToObj() expects UTF-8 or "Lax UTF-8" as input. If the former, then this isn't actually a bug, since the input is illegal. If the latter, then it is a bug. hobbs added on 2004-02-07 02:37:05:
Logged In: YES user_id=72656 let's call this a doc bug ... Tcl_AppendToObj should say something about "undefined behavior when invalid utf-8 sequences are passed". msofer added on 2004-03-27 04:54:37:
Logged In: YES user_id=148712 Doc bug about utf-8 stuff? Better leave it to people who know: dgp? dgp added on 2004-03-27 04:58:56:
Logged In: YES user_id=80530 I'm the wrong guy for the prescribed fix. | ||||
