Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-03-27
04:58 • Ticket [821499ffff] Tcl_AppendToObj disobeys length status still Open with ... artifact: a933a958da user: dgp
04:54 • Ticket [821499ffff]: 5 changes artifact: 52635e6667 user: msofer
2004-02-07
02:37 • Ticket [821499ffff]: 4 changes artifact: 8f9c197635 user: hobbs
2003-10-11
07:14 • Ticket [821499ffff]: 4 changes artifact: 1c5d31f7e8 user: jenglish
2003-10-10
21:38 • New ticket [821499ffff]. artifact: 0d46d633ee user: dgp

Tcl_AppendToObj disobeys length

Open821499ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2003-10-10 21:38:50
#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.
jenglishplain2003-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.
hobbsplain2004-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".
msoferplain2004-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?
dgpplain2004-03-27 04:58:56
Logged In: YES 
user_id=80530

I'm the wrong guy for
the prescribed fix.
Log in (anonymous is fine) to add a comment.