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
hcreate.c.diff
Description: hcreate.c.diff
_______________________________________________ [email protected] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "[email protected]"
