From 9dc235b59cfde0edf3e2a5b1dea32483c99c4ac4 Mon Sep 17 00:00:00 2001 From: Diomidis Spinellis Date: Wed, 20 Feb 2019 00:59:21 +0200 Subject: [PATCH] Avoid array index out of range Issue: #2140 --- googletest/docs/primer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/docs/primer.md b/googletest/docs/primer.md index 6344ba33..1d995574 100644 --- a/googletest/docs/primer.md +++ b/googletest/docs/primer.md @@ -122,7 +122,7 @@ To provide a custom failure message, simply stream it into the macro using the ```c++ ASSERT_EQ(x.size(), y.size()) << "Vectors x and y are of unequal length"; -for (int i = 0; i < x.size(); ++i) { +for (int i = 0; i < std::min(x.size(), y.size()); ++i) { EXPECT_EQ(x[i], y[i]) << "Vectors x and y differ at index " << i; } ```