Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2012-12-23
02:22 • Closed ticket [3598150fff]: TclDStringToObj may trigger leak plus 9 other ch... artifact: 148928c6dc user: ferrieux
2012-12-22
13:21 • New ticket [3598150fff]. artifact: 06f637206d user: afredd

TclDStringToObj may trigger leak

Closed / Fixed3598150fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 14 years ago
Descriptionplain2012-12-22 13:21:19
While skimming thro' the new 8.6 source code, i spotted
something that lloked fishy in tclUtil.c.

If TclDStringToObj() is called on a DString whose length is zero,
but which has had its string allocated, then it still needs an
explicit call to Tcl_DStringFree. The documentation suggests
this is not necessary.

It looks to me like the first if block: if (dsPtr->length == 0)
is wrong and should be removed.


I've not tested this, so i may be missing something obvious.

Merry Xmas!
ferrieuxplain2012-12-23 02:22:58
Good catch ! Fixed in trunk.

Note that, instead of purely removing that "if", I preserved it inside the static alloc case, because it corresponds to the overwhelming use case of a freshly created, empty DString, which deserves to be fast.
Log in (anonymous is fine) to add a comment.