Skip site navigation (1)Skip section navigation (2)
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
This is a multi-part message in MIME format.

------_=_NextPart_001_01CB13AC.D19F6BB9
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

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. =20

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 =3D SLIST_FIRST(&htable[idx]);
               SLIST_REMOVE_HEAD(&htable[idx], link);
-              free(ie->ent.key);
               free(ie);
          }
     }

 <<hcreate.c.diff>>=20

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


------_=_NextPart_001_01CB13AC.D19F6BB9
Content-Type: application/octet-stream;
	name="hcreate.c.diff"
Content-Transfer-Encoding: base64
Content-Description: hcreate.c.diff
Content-Disposition: attachment;
	filename="hcreate.c.diff"

LS0tIGhjcmVhdGUuYwkyMDEwLTA2LTI0IDEwOjM5OjA0LjAwMDAwMDAwMCAtMDQwMAorKysgaGNy
ZWF0ZS5jLm5ldwkyMDEwLTA2LTI0IDEwOjM5OjE4LjAwMDAwMDAwMCAtMDQwMApAQCAtMTQyLDcg
KzE0Miw2IEBACiAJCXdoaWxlICghU0xJU1RfRU1QVFkoJmh0YWJsZVtpZHhdKSkgewogCQkJaWUg
PSBTTElTVF9GSVJTVCgmaHRhYmxlW2lkeF0pOwogCQkJU0xJU1RfUkVNT1ZFX0hFQUQoJmh0YWJs
ZVtpZHhdLCBsaW5rKTsKLQkJCWZyZWUoaWUtPmVudC5rZXkpOwogCQkJZnJlZShpZSk7CiAJCX0K
IAl9Cg==

------_=_NextPart_001_01CB13AC.D19F6BB9--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5AA430FFE4486C448003201AC83BC85EB681E0>