]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(main): Make sure c1 is not -1 before using it as an
authorJim Meyering <jim@meyering.net>
Fri, 14 Mar 1997 03:59:21 +0000 (03:59 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 14 Mar 1997 03:59:21 +0000 (03:59 +0000)
array index.  Patch from Greg McGary.  Although this is truly a
bug, I believe it would not cause tr to misbehave on most systems.
I could not construct a test case with which this bug causes tr
to generate invalid output.

src/tr.c

index da9b2f38185ebe451e587d6fdb756dc9a8004900..7005ae33155f3bc899e4b87054a18772cec3c354 100644 (file)
--- a/src/tr.c
+++ b/src/tr.c
@@ -2033,7 +2033,7 @@ construct in string1 must be aligned with a corresponding construct\n\
              else
                {
                  /* The following should have been checked by validate...  */
-                 if (c2 == -1)
+                 if (c1 == -1 || c2 == -1)
                    break;
                  xlate[c1] = c2;
                }