Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-04-23
18:56 • Closed ticket [940281ffff]: Tcl_FSJoinPath not as documented plus 7 other ch... artifact: afc47934ff user: vincentdarley
03:30 • Ticket [940281ffff]: 4 changes artifact: d6d6e41be4 user: dgp
03:30 • Add attachment 940281.patch to ticket [940281ffff] artifact: 6db25f341f user: dgp
2004-04-22
20:04 • New ticket [940281ffff] Tcl_FSJoinPath not as documented. artifact: f3751f34e4 user: dgp

Tcl_FSJoinPath not as documented

Closed / Fixed940281ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2004-04-22 20:04:58
Docs claim that Tcl_FSJoinPath returns
a (Tcl_Obj *) -- the joined path.  However,
it sometimes returns NULL instead.

Notably, it returns NULL if an invalid list
is passed in as the listObj argument.
That makes some sense, though a
Tcl_Panic() might be just a suitable.
The caller is simply broken.  Either
way that should be documented.

The more serious problem is when
listObj is a valid list, but a value of
0 is passed as the elements argument.
Then NULL is returned instead of an
empty string path.  This  breaks
simple uses like:

 elements = Tcl_FSSplitPath(path, &count);
 Tcl_IncrRefCount(elements);
 parent = Tcl_FSJoinPath(elements, count -1);
 Tcl_IncrRefCount(parent);       /* possible CRASH! */
 Tcl_ListObjIndex(NULL, elements, count - 1, &tail);
 Tcl_IncrRefCount(tail);
 Tcl_DecrRefCount(elements);
dgpplain2004-04-23 03:30:23
File Added - 84717: 940281.patch

Logged In: YES 
user_id=80530

 Here's a possible patch to try.
Causes no harm to the test
suite here.
vincentdarleyplain2004-04-23 18:56:01
Logged In: YES 
user_id=32170

Thank you.  Will commit fix asap.
Log in (anonymous is fine) to add a comment.

Attachments: