[DragonFlyBSD - Submit #1398] hdestroy(3) restricts hash key to point to malloc'ed space
sigttou
bugtracker-admin at leaf.dragonflybsd.org
Fri Oct 2 23:14:33 PDT 2026
Issue #1398 has been updated by sigttou.
File 1398-manual-example-cleanup.patch added
The existing fix passes local ownership and cleanup tests. I have only identified bc as a user of these functions, and it never calls hdestroy. glibc, FreeBSD, and NetBSD do not free keys in hdestroy either.
Could the existing fix be applied? The attached supplemental patch updates the manual example to free its keys explicitly.
----------------------------------------
Submit #1398: hdestroy(3) restricts hash key to point to malloc'ed space
http://bugs.dragonflybsd.org/issues/1398#change-14756
* Author: Anonymous
* Status: In Progress
* Priority: Normal
* Category: Userland
* Target version: 6.4
----------------------------------------
Salute.
hdestroy(3) frees the memory pointed to by the hash key. In other words it expects the user to always have malloc()'ed rather than used static allocation for the hash key. This doesn't apply to the data associated with the key.
Although POSIX standard doesn't say much on this particular topic:
# This is unnecessarily restrictive. If the user wants static allocation, we should allow this. If she wants dynamic then let *her* free the memory she malloc()'ed.
# It is in conflict with the example code in the POSIX page. The code segfaults if you add an hdestroy() call in the end of it.
# Programs that target other implementations may segfault in DragonFly (that'show I discovered it). AFAIK sunOS 5.10 and a recent glibc work fine, whereas {Net, Free, DragonFly}BSD all are affected because they share the same code. (One could argue that all programs written with the *BSD version in mind would
result in a memory leak. But still I think these programs (if any) should be fixed.)
Any thoughts ?
Cheers,
Stathis
---Files--------------------------------
hdestroy-3-Don-t-call-free-3-for-each-hash-key.patch (2.27 KB)
1398-manual-example-cleanup.patch (1.63 KB)
--
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account
More information about the Submit
mailing list