Skip to content

Commit ad383b2

Browse files
authored
Fix value pointed to by _NSGetArgc() on macOS
1 parent a868e61 commit ad383b2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

googletest/src/gtest.cc

+16
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@
146146
# define vsnprintf _vsnprintf
147147
#endif // GTEST_OS_WINDOWS
148148

149+
#if GTEST_OS_MAC
150+
# ifndef GTEST_OS_IOS
151+
# include <crt_externs.h>
152+
# endif
153+
#endif
154+
149155
namespace testing {
150156

151157
using internal::CountIf;
@@ -5341,6 +5347,16 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
53415347
}
53425348
}
53435349

5350+
// Fix the value of *_NSGetArgc() on macOS, but iff
5351+
// *_NSGetArgv() == argv
5352+
#if GTEST_OS_MAC
5353+
# ifndef GTEST_OS_IOS
5354+
if (*_NSGetArgv() == argv) {
5355+
*_NSGetArgc() = *argc;
5356+
}
5357+
# endif
5358+
#endif
5359+
53445360
if (g_help_flag) {
53455361
// We print the help here instead of in RUN_ALL_TESTS(), as the
53465362
// latter may not be called at all if the user is using Google

0 commit comments

Comments
 (0)