Package: libxdg-basedir
Severity: normal
Tags: patch

Hello,

When running valgrind on my program using libxdg-basedir, it reports the
following memory leak:

==25556== 19 bytes in 1 blocks are definitely lost in loss record 1 of 3
==25556==    at 0x402601E: malloc (vg_replace_malloc.c:207)
==25556==    by 0x40440A5: xdgGetEnv (basedir.c:187)
==25556==    by 0x4044524: xdgUpdateData (basedir.c:321)
==25556==    by 0x40446CB: xdgInitHandle (basedir.c:125)
==25556==    by 0x804DC46: parse_command_line_parameters (pcompmgr.c:128)
==25556==    by 0x804DF29: main (pcompmgr.c:226)

I guess it's because cacheHome on line 187 (basedir.c) is never freed. I
have  attached to  this  email a  patch  that works  fine  for me,  e.g.
valgrind  is   happy  with  it,  but   as  I'm  not   so  familiar  with
libxdg-basedir source code so I might be wrong.

Regards,
Arnaud Fontaine

-- System Information:
Debian Release: squeeze/sid
  APT prefers experimental
  APT policy: (990, 'experimental'), (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-maggie-1
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

From a22a544c38e4bff9b05c53bf5874de6515d14e39 Mon Sep 17 00:00:00 2001
From: Arnaud Fontaine <ar...@debian.org>
Date: Wed, 29 Jul 2009 01:33:18 +0200
Subject: [PATCH] Fixed memory leak on cacheHome.

---
 src/basedir.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/basedir.c b/src/basedir.c
index b85a2d1..222d10c 100644
--- a/src/basedir.c
+++ b/src/basedir.c
@@ -153,6 +153,11 @@ static void xdgFreeData(xdgCachedData *cache)
 			free(cache->configHome);
 		cache->configHome = 0;
 	}
+	if (cache->cacheHome)
+	{
+		free(cache->cacheHome);
+		cache->cacheHome = 0;
+	}
 	xdgFreeStringList(cache->searchableDataDirectories);
 	cache->searchableDataDirectories = 0;
 	xdgFreeStringList(cache->searchableConfigDirectories);
-- 
1.6.3.3

Attachment: pgpTZtxZigE3b.pgp
Description: PGP signature

Reply via email to