Subject: Re: misc/22479: Memory leak in arp
To: None <bo@helleskov.dk>
From: Robert Elz <kre@munnari.OZ.AU>
List: netbsd-bugs
Date: 08/14/2003 19:56:24
    Date:        Thu, 14 Aug 2003 09:46:32 +0000 (UTC)
    From:        bo@helleskov.dk
    Message-ID:  <20030814094632.E767B11152@narn.netbsd.org>

  | The arp command allocates memory in two places.
  | In line 415 and and line 490, but it never calls free.

But it does exit, that's enough.

  | >How-To-Repeat:
  | Since arp only allocates a low amount of memory (on my machine if
  | was 674 bytes) you need to run it a couple of hundred thousand times
  | to watch how memory start to disappear.

Have you actually observed that happen, or is this just a presumption
of what you believe will happen?

If you've observed memory "disappearing" - what memory is that, and
how was it observed?

All memory allocated by a program gets released when the program exits.
Calling free() before exit() (except in programs where there might
really be memory leak problems, and everything needs to be accounted for
as part of debugging real bugs) is just a waste of cpu cycles.

  | >Fix:
  | I've created a patch that works

If there was a bug that needed fixing here, you'd want to generate your
patch with "diff -u" instead of just "diff".   But there isn't, so it
doesn't matter this time.

kre