Skip to content

Commit db77e18

Browse files
authored
[asan] Fix argv array for PyROOT applications (#22768)
* [asan] Fix argv array for PyROOT applications pick these changes from #22746: - The argv array for PyROOT applications was one element too small This fixes 20 failing pyunittests on Windows. Thanks @hageboeck! * clang-format
1 parent 6d55820 commit db77e18

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

bindings/pyroot/pythonizations/src/RPyROOTApplication.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ bool PyROOT::RPyROOTApplication::CreateApplication(int ignoreCmdLineOpts)
4646
char **argv = nullptr;
4747

4848
if (ignoreCmdLineOpts) {
49-
argv = new char *[argc];
49+
// Last argv must be null (see https://en.cppreference.com/cpp/language/main_function)
50+
argv = new char *[argc + 1] {};
5051
} else {
5152
// Retrieve sys.argv list from Python
5253
PyObject *argl = PySys_GetObject("argv");
@@ -57,7 +58,8 @@ bool PyROOT::RPyROOTApplication::CreateApplication(int ignoreCmdLineOpts)
5758
argc = static_cast<int>(size);
5859
}
5960

60-
argv = new char *[argc];
61+
// Last argv must be null (see https://en.cppreference.com/cpp/language/main_function)
62+
argv = new char *[argc + 1] {};
6163

6264
for (int i = 1; i < argc; ++i) {
6365
PyObject *item = PyList_GetItem(argl, i);

0 commit comments

Comments
 (0)