svn commit: r294763 - stable/9/lib/libc/stdlib

Pedro F. Giffuni pfg at FreeBSD.org
Tue Jan 26 05:04:38 UTC 2016


Author: pfg
Date: Tue Jan 26 05:04:36 2016
New Revision: 294763
URL: https://svnweb.freebsd.org/changeset/base/294763

Log:
  Revert r279011:
  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 revert of the original merge: this function was rewritten
  in 11-current.
  
  Reported by:	Markiyan Kushnir
  Obtained from:	NetBSD (CVS rev. 1.7, 1.8)

Modified:
  stable/9/lib/libc/stdlib/tdelete.c
Directory Properties:
  stable/9/lib/libc/   (props changed)

Modified: stable/9/lib/libc/stdlib/tdelete.c
==============================================================================
--- stable/9/lib/libc/stdlib/tdelete.c	Tue Jan 26 04:51:44 2016	(r294762)
+++ stable/9/lib/libc/stdlib/tdelete.c	Tue Jan 26 05:04:36 2016	(r294763)
@@ -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.2 1999/09/16 11:45:37 lukem 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;
 }


More information about the svn-src-stable-9 mailing list