diff --git a/bindings/pyroot/pythonizations/src/RPyROOTApplication.cxx b/bindings/pyroot/pythonizations/src/RPyROOTApplication.cxx index 67f11364399e3..48fa9b8dc9bea 100644 --- a/bindings/pyroot/pythonizations/src/RPyROOTApplication.cxx +++ b/bindings/pyroot/pythonizations/src/RPyROOTApplication.cxx @@ -46,7 +46,8 @@ bool PyROOT::RPyROOTApplication::CreateApplication(int ignoreCmdLineOpts) char **argv = nullptr; if (ignoreCmdLineOpts) { - argv = new char *[argc]; + // Last argv must be null (see https://en.cppreference.com/cpp/language/main_function) + argv = new char *[argc + 1] {}; } else { // Retrieve sys.argv list from Python PyObject *argl = PySys_GetObject("argv"); @@ -57,7 +58,8 @@ bool PyROOT::RPyROOTApplication::CreateApplication(int ignoreCmdLineOpts) argc = static_cast(size); } - argv = new char *[argc]; + // Last argv must be null (see https://en.cppreference.com/cpp/language/main_function) + argv = new char *[argc + 1] {}; for (int i = 1; i < argc; ++i) { PyObject *item = PyList_GetItem(argl, i);