[libvirt] [PATCH 2/8] Fix memory leak in logging setup

Eric Blake eblake at redhat.com
Wed Dec 1 19:21:51 UTC 2010


On 12/01/2010 10:26 AM, Daniel P. Berrange wrote:
> The logging setup requires const char * strings, but the
> virLogSetFromEnv() strdup's the env variables, thus causing
> a memory leak
> 
> * src/util/logging.c: Avoid strdup'ing env variables
> ---
>  src/util/logging.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/util/logging.c b/src/util/logging.c
> index d65dec0..83cc358 100644
> --- a/src/util/logging.c
> +++ b/src/util/logging.c
> @@ -980,8 +980,8 @@ void virLogSetFromEnv(void) {
>          virLogParseDefaultPriority(debugEnv);
>      debugEnv = getenv("LIBVIRT_LOG_FILTERS");
>      if (debugEnv && *debugEnv)
> -        virLogParseFilters(strdup(debugEnv));
> +        virLogParseFilters(debugEnv);

ACK; independently useful to push now, even if the rest of your series
is not ready for prime time.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101201/330b379b/attachment-0001.sig>


More information about the libvir-list mailing list