svn commit: r279010 - stable/10/lib/libc/stdlib

Pedro F. Giffuni pfg at FreeBSD.org
Thu Feb 19 16:24:29 UTC 2015


Author: pfg
Date: Thu Feb 19 16:24:27 2015
New Revision: 279010
URL: https://svnweb.freebsd.org/changeset/base/279010

Log:
  MFC	r278301, r278315:
  tdelete(3): don't delete the node we are about to return.
  
  CID:		272528
  Obtained from:	NetBSD (CVS rev. 1.4)

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	Thu Feb 19 16:19:00 2015	(r279009)
+++ stable/10/lib/libc/stdlib/tdelete.c	Thu Feb 19 16:24:27 2015	(r279010)
@@ -14,7 +14,7 @@
 #include <sys/cdefs.h>
 #if 0
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
+__RCSID("$NetBSD: tdelete.c,v 1.6 2012/06/25 22:32:45 abs Exp $");
 #endif /* LIBC_SCCS and not lint */
 #endif
 __FBSDID("$FreeBSD$");
@@ -25,9 +25,9 @@ __FBSDID("$FreeBSD$");
 
 
 /*
- * delete node with given key
+ * find a node with given key
  *
- * vkey:   key to be deleted
+ * vkey:   key to be found
  * vrootp: address of the root of the tree
  * compar: function to carry out node comparisons
  */
@@ -65,7 +65,8 @@ tdelete(const void * __restrict vkey, vo
 			q->rlink = (*rootp)->rlink;
 		}
 	}
-	free(*rootp);				/* D4: Free node */
+	if (p != *rootp)
+		free(*rootp);			/* D4: Free node */
 	*rootp = q;				/* link parent to new node */
 	return p;
 }


More information about the svn-src-all mailing list