diff --git a/mercurial/cext/osutil.c b/mercurial/cext/osutil.c index 460f8bf58020a67b4c2e37449661c1b7ae93a25c_bWVyY3VyaWFsL2NleHQvb3N1dGlsLmM=..d6227c6c0814cf2c07b87d6019717f5b11ce7b2b_bWVyY3VyaWFsL2NleHQvb3N1dGlsLmM= 100644 --- a/mercurial/cext/osutil.c +++ b/mercurial/cext/osutil.c @@ -798,6 +798,14 @@ char *argvend; extern void Py_GetArgcArgv(int *argc, char ***argv); Py_GetArgcArgv(&argc, &argv); + /* Py_GetArgcArgv may not do much if a custom python + * launcher is used that doesn't record the information + * it needs. Let's handle this gracefully instead of + * segfaulting. */ + if (argv != NULL) + argvend = argvstart = argv[0]; + else + argvend = argvstart = NULL; /* Check the memory we can use. Typically, argv[i] and * argv[i + 1] are continuous. */ @@ -801,7 +809,6 @@ /* Check the memory we can use. Typically, argv[i] and * argv[i + 1] are continuous. */ - argvend = argvstart = argv[0]; for (i = 0; i < argc; ++i) { if (argv[i] > argvend || argv[i] < argvstart) break; /* not continuous */