aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--googletest/src/gtest.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index d64c18d..9a17180 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -6700,17 +6700,17 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
}
if (remove_flag) {
- // Shift the remainder of the argv list left by one. Note
- // that argv has (*argc + 1) elements, the last one always being
- // NULL. The following loop moves the trailing NULL element as
- // well.
- for (int j = i; j != *argc; j++) {
- argv[j] = argv[j + 1];
+ // Shift the remainder of the argv list left by one.
+ for (int j = i + 1; j < *argc; ++j) {
+ argv[j - 1] = argv[j];
}
// Decrements the argument count.
(*argc)--;
+ // Terminate the array with nullptr.
+ argv[*argc] = nullptr;
+
// We also need to decrement the iterator as we just removed
// an element.
i--;