File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
bindings/python/google_benchmark Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -14,16 +14,18 @@ namespace {
14
14
namespace nb = nanobind;
15
15
16
16
std::vector<std::string> Initialize (const std::vector<std::string>& argv) {
17
- // The `argv` pointers here become invalid when this function returns, but
18
- // benchmark holds the pointer to `argv[0]`. We create a static copy of it
19
- // so it persists, and replace the pointer below.
20
- static std::string executable_name (argv[0 ]);
21
17
std::vector<char *> ptrs;
22
18
ptrs.reserve (argv.size ());
23
19
for (auto & arg : argv) {
24
20
ptrs.push_back (const_cast <char *>(arg.c_str ()));
25
21
}
26
- ptrs[0 ] = const_cast <char *>(executable_name.c_str ());
22
+ if (!ptrs.empty ()) {
23
+ // The `argv` pointers here become invalid when this function returns, but
24
+ // benchmark holds the pointer to `argv[0]`. We create a static copy of it
25
+ // so it persists, and replace the pointer below.
26
+ static std::string executable_name (argv[0 ]);
27
+ ptrs[0 ] = const_cast <char *>(executable_name.c_str ());
28
+ }
27
29
int argc = static_cast <int >(argv.size ());
28
30
benchmark::Initialize (&argc, ptrs.data ());
29
31
std::vector<std::string> remaining_argv;
You can’t perform that action at this time.
0 commit comments