| Submitter | Stefan Hajnoczi |
|---|---|
| Date | Dec. 6, 2011, 11:01 a.m. |
| Message ID | <1323169274-31657-8-git-send-email-stefanha@linux.vnet.ibm.com> |
| Download | mbox | patch |
| Permalink | /patch/129627/ |
| State | New |
| Headers | show |
Comments
Patch
diff --git a/os-win32.c b/os-win32.c index 8ad5fa1..8523d8d 100644 --- a/os-win32.c +++ b/os-win32.c @@ -44,6 +44,13 @@ int setenv(const char *name, const char *value, int overwrite) char *string = g_malloc(length); snprintf(string, length, "%s=%s", name, value); result = putenv(string); + + /* Windows takes a copy and does not continue to use our string. + * Therefore it can be safely freed on this platform. POSIX code + * typically has to leak the string because according to the spec it + * becomes part of the environment. + */ + g_free(string); } return result; }