Unix Technical Forum

Re: Patch for memory leak in snmpd/parse.y

This is a discussion on Re: Patch for memory leak in snmpd/parse.y within the mailing.openbsd.tech forums, part of the OpenBSD category; --> On 2/23/08, Claudio Jeker <cjeker@diehard.n-r-g.com> wrote: > Please use > while ((h = TAILQ_FIRST(&al)) != NULL) { > TAILQ_REMOVE(&al, ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-24-2008, 02:35 AM
Matthew Dempsky
 
Posts: n/a
Default Re: Patch for memory leak in snmpd/parse.y

On 2/23/08, Claudio Jeker <cjeker@diehard.n-r-g.com> wrote:
> Please use
> while ((h = TAILQ_FIRST(&al)) != NULL) {
> TAILQ_REMOVE(&al, h, entry);
> free(h);
> }
> to free the list. Your solution scares me to death -- it may be fine in
> this case but it will return a corrupt TAILQ head node and if al would be
> reused it would cause a use-after-free.
> Don't put bad examples into the tree because somebody may copy it.


Sorry, you're right. I've not used the queue(3) functions much, and
the patch I submitted is derived from the "Faster TailQ Deletion."
code sample I found in OS X's queue(3) man pages, but I missed the
final TAILQ_INIT call. (Of course, I should have checked OpenBSD's.)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:50 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com