Date: Thu, 19 Feb 2015 16:24:28 +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: r279010 - stable/10/lib/libc/stdlib Message-ID: <201502191624.t1JGOSr7056777@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502191624.t1JGOSr7056777>