Artifacts Associated With Ticket 219112
Ticket change [45d7ecdda1] (rid 99413) by nobody on 2000-10-26 01:10:58:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
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 - foundin initialized to: "obsolete: 8.3.1"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "69. Other"
- title initialized to:
missing Tcl_DStringFree() in win/tclWinPipe.c (very simple)
- type initialized to: "Bug"
Ticket change [5ac8211fd0] (rid 118204) by welch on 2000-10-26 08:34:57:
- closedate changed to: "2000-10-26T01:34:57"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [2fe16c759b] (rid 93147) by dgp on 2001-04-20 02:34:46:
- closedate changed to: "2001-04-19T19:34:46"
- closer changed to: "dgp"
- subsystem changed to: "27. Channel Types"