Date: Tue, 26 Jan 2016 04:51:44 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r294762 - stable/10/lib/libc/stdlib Message-ID: <201601260451.u0Q4pi7M076346@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Tue Jan 26 04:51:44 2016 New Revision: 294762 URL: https://svnweb.freebsd.org/changeset/base/294762 Log: Revert r279010: tdelete(3): don't delete the node we are about to return. The original change, from NetBSD, was bogus; introduced a memory leak and and broke POSIX. By reverting we actually match NetBSD's latest revision. This is a direct commit to 10 since this function was rewritten in 11-current. Reported by: Markiyan Kushnir Obtained from: NetBSD (CVS rev. 1.7, 1.8) Modified: stable/10/lib/libc/stdlib/tdelete.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/stdlib/tdelete.c ============================================================================== --- stable/10/lib/libc/stdlib/tdelete.c Tue Jan 26 04:48:24 2016 (r294761) +++ stable/10/lib/libc/stdlib/tdelete.c Tue Jan 26 04:51:44 2016 (r294762) @@ -1,4 +1,4 @@ -/* $NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $ */ +/* $NetBSD: tdelete.c,v 1.8 2016/01/20 20:47:41 christos Exp $ */ /* * Tree search generalized from Knuth (6.2.2) Algorithm T just like @@ -14,7 +14,7 @@ #include <sys/cdefs.h> #if 0 #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: tdelete.c,v 1.6 2012/06/25 22:32:45 abs Exp $"); +__RCSID("$NetBSD: tdelete.c,v 1.8 2016/01/20 20:47:41 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #endif __FBSDID("$FreeBSD$"); @@ -25,9 +25,9 @@ __FBSDID("$FreeBSD$"); /* - * find a node with given key + * delete node with given key * - * vkey: key to be found + * vkey: key to be deleted * vrootp: address of the root of the tree * compar: function to carry out node comparisons */ @@ -65,8 +65,7 @@ tdelete(const void * __restrict vkey, vo q->rlink = (*rootp)->rlink; } } - if (p != *rootp) - free(*rootp); /* D4: Free node */ + free(*rootp); /* D4: Free node */ *rootp = q; /* link parent to new node */ return p; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601260451.u0Q4pi7M076346>