NetBSD Problem Report #41564

From  Tue Jun  9 18:40:42 2009
Return-Path: <>
Received: from ( [])
	by (Postfix) with ESMTP id 2F65163BF62
	for <>; Tue,  9 Jun 2009 18:40:42 +0000 (UTC)
Message-Id: <>
Date: Tue,  9 Jun 2009 18:40:41 +0000 (UTC)
Subject: hdestroy(3) restricts ENTRY.key to point to malloc'ed space.
X-Send-Pr-Version: www-1.0

>Number:         41564
>Category:       lib
>Synopsis:       hdestroy(3) restricts ENTRY.key to point to malloc'ed space.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 09 18:45:00 +0000 2009
>Originator:     Stathis Kamperis
>Release:        NetBSD 5.0_STABLE
Aristotle University of Thessaloniki
NetBSD voyager 5.0_STABLE NetBSD 5.0_STABLE (MYGENERIC) #4: Sat May 23 15:45:44 EEST 2009  root@voyager:/usr/obj/sys/arch/i386/compile/MYGENERIC i386
hdestroy(3) frees the memory pointed to by ENTRY.key. In other words it expects the user to have malloc'ed rather than used static allocation. This refers only to ENTRY.key and not to

Although the POSIX standard doesn't say anything on this particular topic:

1) This is unnecessarily restrictive.  If the user wants static allocation fine; if she wants dynamic then let *her* free the memory she malloc'ed.

2) It is in conflict with the example code in the POSIX page (the code segfaults).

3) Programs that target other implementations may segfault (that's how I discovered it). AFAIK sunOS 5.10 and a recent glibc work fine, whereas {Net, Free, DragonFly}BSD all are affected.
Try to call hdestroy() in the example code of:

Just remove the following line from hdestroy():

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD:,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.