From: David Leppik <dleppik@vocalabs.com>
To: linux-kernel@vger.kernel.org
Subject: PROBLEM: memory leak in LIST_*, TAILQ_* man page
Date: Sun, 16 Oct 2005 20:50:49 -0500 [thread overview]
Message-ID: <43530379.6040504@vocalabs.com> (raw)
My apologies if this is the wrong mailing list; I didn't find a better one.
The man page for TAILQ_REMOVE, etc. contains the following sample code:
while (head.tqh_first != NULL)
TAILQ_REMOVE(&head, head.tqh_first, entries);
I checked /usr/include/sys/queue.h and, sure enough, TAILQ_REMOVE
doesn't free
head.tqh_first. Nor should it-- this isn't Objective-C, after all. :-)
It should be something like:
while (head.tqh_first != NULL) {
np = head.tqh_first;
TAILQ_REMOVE(&head, np, entries);
free(np);
}
The same bug is repeated for all the data structures in this man page.
In this day and age of Java, C#, and Objective-C programmers, kids these
days
are less likely to remember to clean up after themselves. Therefore it was
particularly jarring to find this bug. Ten years ago I might have
laughed it
off. That's probably why it's been around for so long.
David
next reply other threads:[~2005-10-17 1:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-17 1:50 David Leppik [this message]
2005-10-17 2:18 ` [OT] Re: PROBLEM: memory leak in LIST_*, TAILQ_* man page YOSHIFUJI Hideaki / 吉藤英明
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43530379.6040504@vocalabs.com \
--to=dleppik@vocalabs.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.