|
2001-04-20
| ||
| 02:34 | • Ticket [219112ffff] missing Tcl_DStringFree() in win/tclWinPipe.c (very simple)... artifact: 2fe16c759b user: dgp | |
|
2000-10-26
| ||
| 08:34 | • Closed ticket [219112ffff]. artifact: 5ac8211fd0 user: welch | |
| 01:10 | • New ticket [219112ffff]. artifact: 45d7ecdda1 user: nobody | |
missing Tcl_DStringFree() in win/tclWinPipe.c (very simple)
Closed / Fixed219112ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:10:58
OriginalBugID: 6041 Bug
Version: 8.3.1
SubmitDate: '2000-07-24'
LastModified: '2000-07-25'
Severity: MED
Status: Released
Submitter: techsupp
ChangedBy: ericm
OS: All
FixedDate: '2000-07-25'
FixedInVersion: 8.4a2
ClosedDate: '2000-07-24'
Name:
marc herbert
ReproducibleScript:
Simple Tcl_DStringFree() call missing
Possible memory leak
Patch self-explanatory
Patch:
===================================================================
RCS file: RCS/tclWinPipe.c,v
retrieving revision 1.1
diff -c -r1.1 tclWinPipe.c
*** tclWinPipe.c 2000/07/24 09:38:53 1.1
--- tclWinPipe.c 2000/07/24 09:41:09
***************
*** 1569,1574 ****
--- 1569,1575 ----
Tcl_DStringAppend(&ds, "\"", 1);
}
}
+ Tcl_DStringFree(linePtr);
Tcl_WinUtfToTChar(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds), linePtr);
Tcl_DStringFree(&ds);
}
PatchFiles:
win/tclWinPipe.c
I don't think that this modification is necessary; the DString referred to as linePtr in the function indicated above is managed by the calling function, not by BuildCommandLine itself. See the function TclpCreateProcess, at line 1232 of tclWinPipe.c. The DString is free'd at that point.
Eric Melski The Other Tcl Guy
ericm at ajubasolutions.com Ajuba Solutions
-- 07/24/2000 ericm
Éric,
I think you're wrong. Let's see the Tcl man pages :
> Tcl_DStringInit initializes a dynamic string to zero
> length. The Tcl_DString structure must have been allocated by
> the caller. No assump tions are made about the current
> state of the structure; anything already in it is discarded.
And in particular :
> If the structure has been used previously, Tcl_DStringFree
> should be called first to free up any memory allocated for the
> old string.
This is because a "brutal" Tcl_DStringInit () may leave the possibly
already dynamic allocated memory unreferenced.
=> garbage, memory leak.
The Tcl_DStringFree () you mention (tclWinPipe.c:1232) is too late. A
"brutal" Tcl_DStringInit () has occured before, thanks to the
Tcl_WinUtfToTChar() call seen in my patch just above.
--------------------
In short :
BuildCommandLine () gets a arguments already initialized (we both
agree on that point) :
static void
BuildCommandLine(
...
Tcl_DString *linePtr) /* Initialized Tcl_DString that receives the
* command line (TCHAR). */
)
But it does a second "over-Tcl_DStringInit ()" on it, via
Tcl_WinUtfToTChar(), without freeing it first, and this is wrong.
Sincerely,
--
Marc Herbert | GIE Dyade (Bull/INRIA)
[email protected] | http://www.dyade.fr/
tel: +33 4 7661 5258 | VASY Project
fax: +33 4 7661 5252 | http://www.inrialpes.fr/vasy
----
Yes, you are right. Thanks for straightening me out. I've applied your patch and committed it to CVS. The fix will be included in Tcl 8.4a2.
Eric Melski The Other Tcl Guy
ericm at ajubasolutions.com Ajuba Solutions
-- 07/25/2000 ericm
welch Closed ticket [219112ffff].
[History diff]2000-10-26 08:34:57
dgp Ticket [219112ffff]: 3 changes
[History diff]2001-04-20 02:34:46
Log in (anonymous is fine) to add a comment.