diff options
author | moritz <> | 2006-04-04 11:21:50 +0000 |
---|---|---|
committer | moritz <> | 2006-04-04 11:21:50 +0000 |
commit | 98d91b101f726e2dc971f807de9ed123cb2b80e4 (patch) | |
tree | 5323c35c56bef0dde8489a327c1c09f6dd135365 /src/lib/libc/stdlib/tsearch.c | |
parent | fd6d62e96b81f055cd4c12eab824a3d30d264979 (diff) | |
download | openbsd-98d91b101f726e2dc971f807de9ed123cb2b80e4.tar.gz openbsd-98d91b101f726e2dc971f807de9ed123cb2b80e4.tar.bz2 openbsd-98d91b101f726e2dc971f807de9ed123cb2b80e4.zip |
When tdelete() is used to delete the root node, don't return a
pointer to the freed root node, but return a pointer to the new
root node. POSIX does not define, what should be returned in
that case.
Fixes Coverity CID 2528.
ok millert@ otto@
Diffstat (limited to 'src/lib/libc/stdlib/tsearch.c')
-rw-r--r-- | src/lib/libc/stdlib/tsearch.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lib/libc/stdlib/tsearch.c b/src/lib/libc/stdlib/tsearch.c index a5d0c2b9b3..667c57731b 100644 --- a/src/lib/libc/stdlib/tsearch.c +++ b/src/lib/libc/stdlib/tsearch.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tsearch.c,v 1.5 2005/03/30 18:51:49 pat Exp $ */ | 1 | /* $OpenBSD: tsearch.c,v 1.6 2006/04/04 11:21:50 moritz Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Tree search generalized from Knuth (6.2.2) Algorithm T just like | 4 | * Tree search generalized from Knuth (6.2.2) Algorithm T just like |
@@ -86,6 +86,8 @@ tdelete(const void *vkey, void **vrootp, | |||
86 | q->right = (*rootp)->right; | 86 | q->right = (*rootp)->right; |
87 | } | 87 | } |
88 | } | 88 | } |
89 | if (p == *rootp) | ||
90 | p = q; | ||
89 | free((struct node_t *) *rootp); /* D4: Free node */ | 91 | free((struct node_t *) *rootp); /* D4: Free node */ |
90 | *rootp = q; /* link parent to new node */ | 92 | *rootp = q; /* link parent to new node */ |
91 | return(p); | 93 | return(p); |