aboutsummaryrefslogtreecommitdiff
path: root/misc/tst-tsearch.c
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.de>2001-06-05 13:38:39 +0000
committerAndreas Jaeger <aj@suse.de>2001-06-05 13:38:39 +0000
commit673c34e01c706930c97c922b5ad97febfb6dbf1b (patch)
treec6699315afd14514534e1655e2283b6cfc320554 /misc/tst-tsearch.c
parent76f696fc4ab5c307a4593a7780210dc75e15f5b2 (diff)
downloadglibc-673c34e01c706930c97c922b5ad97febfb6dbf1b.tar
glibc-673c34e01c706930c97c922b5ad97febfb6dbf1b.tar.gz
glibc-673c34e01c706930c97c922b5ad97febfb6dbf1b.tar.bz2
glibc-673c34e01c706930c97c922b5ad97febfb6dbf1b.zip
(mangle_tree): Ensure array indices are within bounds when lag > 0.
Diffstat (limited to 'misc/tst-tsearch.c')
-rw-r--r--misc/tst-tsearch.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/misc/tst-tsearch.c b/misc/tst-tsearch.c
index 06f743bc05..bdefdebba7 100644
--- a/misc/tst-tsearch.c
+++ b/misc/tst-tsearch.c
@@ -1,5 +1,5 @@
/* Test program for tsearch et al.
- Copyright (C) 1997, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -171,8 +171,9 @@ mangle_tree (enum order how, enum action what, void **root, int lag)
if (i >= lag)
k = y[i - lag];
else
- k = y[SIZE - i - 1 + lag];
- j = y[i];
+ /* Ensure that the array index is within bounds. */
+ k = y[(SIZE - i - 1 + lag) % SIZE];
+ j = y[i % SIZE];
break;
case ascending: