qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Weil <sw@weilnetz.de>
Cc: qemu-trivial@nongnu.org, Stefan Hajnoczi <stefanha@gmail.com>,
	Mark <wudx05@gmail.com>, Zhi Hui Li <zhihuili@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] os-win32.c : fix memory leak
Date: Fri, 25 Nov 2011 09:56:14 +0100	[thread overview]
Message-ID: <4ECF582E.9000709@redhat.com> (raw)
In-Reply-To: <4ECE9AED.3070209@weilnetz.de>

On 11/24/2011 08:28 PM, Stefan Weil wrote:
>
> MS claims that putenv is a POSIX function, so I also expected
> that free / f_free is not allowed.
>
> I now wrote a short test which indicates that g_free would work:
> getenv returns a pointer which is completely different from
> the one passed to putenv.

Confirmed by http://source.winehq.org/source/dlls/msvcrt/environ.c.  It 
makes a copy of the string, passes it to SetEnvironmentVariable, and 
frees the copy.  So Windows never even sees the string passed to putenv.

The reason for the dance is that: 1) the underlying Win32 APIs require 
separate arguments for the variable and value; 2) even though in the end 
Wine stores the environment as name=value 
(http://source.winehq.org/source/dlls/ntdll/env.c), it does so in a 
single consecutive block of memory, not as a char* array like POSIX 
does.  While (2) might apply only to Wine, (1) surely applies to Windows 
as well.

Stefan, can you add some of the info to the commit message?

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

  parent reply	other threads:[~2011-11-25  8:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-24  8:27 [Qemu-devel] [PATCH] os-win32.c : fix memory leak Zhi Hui Li
2011-11-24  9:15 ` Mark
2011-11-24 10:27   ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
2011-11-24 19:28     ` Stefan Weil
2011-11-24 20:46       ` Stefan Weil
2011-11-25  8:56       ` Paolo Bonzini [this message]
2011-11-28 10:49 ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ECF582E.9000709@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=sw@weilnetz.de \
    --cc=wudx05@gmail.com \
    --cc=zhihuili@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).