About Archive Tags RSS Feed

 

Free the mallocs!

12 January 2006 21:50

Debian Bugs

I've noticed for a while that there are times when I just don't get any mail from the BTS. I have no idea why.

The same thing happened again with one of my packages, ApacheTop.

I noticed a discussion on debian-devel asking about learning to debug problems, inspired by a bug in the package.

Looking at the bug reports I saw a report had been made a few days earlier. So for fun I posted a quick how to debug this problem message.

After playing around it seemed like my simple solution of removing the offending free was the correct approach - because the code essentially does this:

  • struct *foo = NULL.
  • foo = realloc(size)
  • if ( foo->filename ) free( foo-filename);

The code doesn't NULL-fill the memory which it obtains via the realloc call, so it is liable to always attempt to crash with the free call.

So we have a leak. A small leak. Thankfully the function in question is only called when a new file is opened, which is essentially once per program-startup.

I can live with a leak like that, and so can my users. I insist ;0

New package uploaded now.

P.S. I have clean socks. Take that Mr. Not-Debian-related-blog-entry! :P

| No comments