Overview
| Artifact ID: | 759e2f5cf21ff4e99c78400dd4a6633389b464a5 |
|---|---|
| Ticket: | 623269ffffffffffffffffffffffffffffffffff
mem leak in Tcl_PutEnv. |
| User & Date: | hobbs on 2002-10-14 22:20:33 |
Changes
- assignee changed to: "hobbs"
- cmimetype changed to: "text/plain"
- comment changed to:
From Jean Brouwers mrjean1 -> earthlink.net There is a memory leak in function Tcl_PutEnv() in file generic/tclEnv.c in 8.3.4 and earlier. Haven't checked later versions. The leak does only occur under specific conditions*. Here is an improved implementation for that function. int Tcl_PutEnv(string) CONST char *string;/* Info about environment variable in the * form NAME=value. (native) */ { Tcl_DString nameString; char *name, *value; if (string == NULL) { return 0; } /* * First convert the native string to UTF. Then separate the * string into name and value parts, and call TclSetEnv to do * all of the real work. */ name = Tcl_ExternalToUtfDString(NULL, string, -1, &nameString); value = strchr(name, '='); if (value != NULL && value != name) { value++ = '\0'; TclSetEnv(name, value); } Tcl_DStringFree(&nameString); return 0; } /Jean Brouwers *) In the original code, Tcl_DStringFree(&nameString) is not called if the input string does not contain a '=' or if the first character is '='. A memory leak will occur if string is large enough that additional memory was allocated for nameString. - foundin changed to: "None"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "hobbs"
- subsystem changed to: "08. Environment Variables"
- title changed to: "mem leak in Tcl_PutEnv."
- type changed to: "Patch"