|
2009-12-11
| ||
| 17:48 | • Ticket [2878945fff] Tcl_ExternalToUtf(...dst, dstLen,...) writes to dstdstLen<... artifact: 05587391c8 user: dkf | |
| 10:27 | • Ticket [2878945fff]: 1 change artifact: cce26b342e user: msofer | |
|
2009-10-15
| ||
| 00:43 | • Ticket [2878945fff]: 4 changes artifact: 3fbc2da0d6 user: dgp | |
| 00:31 | • Ticket [2878945fff]: 4 changes artifact: 7165a92f7d user: dgp | |
|
2009-10-14
| ||
| 22:03 | • Ticket [2878945fff]: 4 changes artifact: ec892f38f6 user: dgp | |
| 14:56 | • New ticket [2878945fff]. artifact: da4d956490 user: dgp | |
Tcl_ExternalToUtf(...dst, dstLen,...) writes to dst[dstLen]
Open2878945fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2009-10-14 14:56:01
The docs of Tcl_ExternalToUtf() are unclear on the boundaries of the write buffer. They say "... and up to dstLen converted bytes are stored in dst." which suggests bytes will be written in dst[0] up to dst[dstLen-1]. And that appears to be an accurate description of what the underlying ToUtfProc() does. However, then Tcl_ExternalToUtf() appends a terminating NUL character, and if the ToUtfProc has used all dstLen bytes, T_ETU writes to dst[dstLen].
dgpplain2009-10-14 22:03:21
It should also be noted that no bytes (except that terminating NUL) will be written unless dstLen is at least TCL_UTF_MAX.
dgpplain2009-10-15 00:31:01
Sorry, I missed a line in Tcl_ExternalToUtf(). It decrements dstLen before passing to the ToUtfProc to account for the byte it needs to write NUL into.
dgpplain2009-10-15 00:43:17
no matter what the value of dstLen, writing to the byte *dst must work. That is, don't expect dstLen==0 to work. To get at least one actual character in the output buffer, dstLen must have a minimum value of TCL_UTF_MAX + 1.
msofer Ticket [2878945fff]: 1 change
[History diff]2009-12-11 10:27:21
dkfplain2009-12-11 17:48:17
Maybe this just needs to be documented.
Log in (anonymous is fine) to add a comment.