[PATCH] Minor bug in hdestroy function
Green, Paul
Paul.Green at stratus.com
Thu Jun 24 15:35:37 UTC 2010
The hdestroy function calls the free function on a generation of storage
that it never allocated. It frees the pointer to the key. This can lead
to unpredictable results. I can't find any evidence that the POSIX
standard requires this step, and I can't find any evidence that the
POSIX standard expects the hsearch function to make its own copy of the
key or data items. So I believe the proper fix is to simply delete the
free statement.
Here is the change. I generated the diff against revision 1.4,
downloaded earlier today.
--- hcreate.c 2010-06-24 10:39:04.000000000 -0400
+++ hcreate.c.new 2010-06-24 10:39:18.000000000 -0400
@@ -142,7 +142,6 @@
while (!SLIST_EMPTY(&htable[idx])) {
ie = SLIST_FIRST(&htable[idx]);
SLIST_REMOVE_HEAD(&htable[idx], link);
- free(ie->ent.key);
free(ie);
}
}
<<hcreate.c.diff>>
Thanks
PG
--
Paul Green, Senior Technical Consultant, Stratus Technologies.
Voice: +1 978-461-7557; FAX: +1 978-461-3610; Mobile: +1 (978) 235-2451;
AIM: PaulGreen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hcreate.c.diff
Type: application/octet-stream
Size: 289 bytes
Desc: hcreate.c.diff
Url : http://lists.freebsd.org/pipermail/freebsd-bugs/attachments/20100624/e46ef17d/hcreate.c.obj
More information about the freebsd-bugs
mailing list