Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2012-07-17
05:27 • Closed ticket [3544658fff]: String constants, strlen and sizeof, oh my plus ... artifact: 17eb1725c8 user: dkf
2012-07-16
15:54 • New ticket [3544658fff]. artifact: d97e5c9104 user: stwo

String constants, strlen and sizeof, oh my

Closed / Fixed3544658fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 14 years ago
Descriptionplain2012-07-16 15:54:24
Where do I begin with this one?

tclUtil.c: In function 'UpdateStringOfEndOffset':
tclUtil.c:3432: warning: array size (4) smaller than bound length (5)
tclUtil.c:3432: warning: array size (4) smaller than bound length (5)

Looking at commit [50bdab4682] we can see a variety of fun ways to play with strings, at least one of which is not really correct:
char buffer[TCL_INTEGER_SPACE + sizeof("end") + 1];
...
memcpy(buffer, "end", sizeof("end") + 1);

And other interesting things like:
#define TCL_CLOCK_PREFIX_LEN 14 /* == strlen("::tcl::clock::") */
memcpy(cmdName, "::tcl::clock::", TCL_CLOCK_PREFIX_LEN);

Also, the commit mentions "More ..." But I haven't found other occurrences of these changes.
dkfplain2012-07-17 05:27:35
allow_comments - 1

The "More" refers to the fact that removal of strcpy() from locations where the number of bytes to be copied was *already* known was a long-term project of mine (now largely finished).
Log in (anonymous is fine) to add a comment.