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 ([email protected])
http://compton.nu/

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to