NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/41564: hdestroy(3) restricts ENTRY.key to point to malloc'ed space.
>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
>Organization:
Aristotle University of Thessaloniki
>Environment:
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
>Description:
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 ENTRY.data.
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.
>How-To-Repeat:
Try to call hdestroy() in the example code of:
http://www.opengroup.org/onlinepubs/009695399/functions/hcreate.html
>Fix:
Just remove the following line from hdestroy():
free(ie->ent.key);
Home |
Main Index |
Thread Index |
Old Index