|
From: Tom H. <to...@co...> - 2010-06-12 09:24:44
|
On 12/06/10 03:56, Kevin Partin wrote:
> if ((name = strdup(basename(dup))) == NULL) { // <-- Line 73
> perror(routine);
> free(dup);
> return 8;
> }
>
> Valgrind gives the following message:
>
> ==9726== 58 bytes in 3 blocks are definitely lost in loss record 8 of 19
> ==9726== at 0x4026FDE: malloc (vg_replace_malloc.c:207)
> ==9726== by 0x427144F: strdup (strdup.c:43)
> ==9726== by 0x403D683: analysisConfigLoad (analysisConfigLoad.c:73)
> ==9726== by 0x8062F20: main (clap.c:368)
>
> Can anyone tell me how to fix this leak, if it is really a leak? I have
> nearly identical code that uses dirname instead of basename, and
> valgrind does not report a leak. I use strdup extensively and do not get
> leaks detected with them, so I am assuming the problem is with basename.
> Has anyone seen this behavior before?
You're not freeing the value returned from strdup... You need a
free(name) in there somewhere.
Tom
--
Tom Hughes (to...@co...)
http://compton.nu/
|