]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(mangle_tree): Ensure array indices are within bounds when lag > 0.
authorAndreas Jaeger <aj@suse.de>
Tue, 5 Jun 2001 13:38:39 +0000 (13:38 +0000)
committerAndreas Jaeger <aj@suse.de>
Tue, 5 Jun 2001 13:38:39 +0000 (13:38 +0000)
misc/tst-tsearch.c

index 06f743bc053af8337a55103d90d926fbffee910e..bdefdebba71468d62f5e55dd096d3796204bc053 100644 (file)
@@ -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: