Date: Thu, 24 Jun 2010 10:48:13 -0400 From: "Green, Paul" <Paul.Green@stratus.com> To: <freebsd-bugs@freebsd.org> Subject: [PATCH] Minor bug in hdestroy function Message-ID: <5AA430FFE4486C448003201AC83BC85EB681E0@EXHQ.corp.stratus.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
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
[-- Attachment #2 --]
--- 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);
}
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5AA430FFE4486C448003201AC83BC85EB681E0>
