D6866: osutil: tolerate Py_GetArgcArgv not being set up properly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

D6866: osutil: tolerate Py_GetArgcArgv not being set up properly

martinvonz (Martin von Zweigbergk)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6866

AFFECTED FILES
  mercurial/cext/osutil.c

CHANGE DETAILS

diff --git a/mercurial/cext/osutil.c b/mercurial/cext/osutil.c
--- a/mercurial/cext/osutil.c
+++ b/mercurial/cext/osutil.c
@@ -798,10 +798,17 @@
  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. */
- argvend = argvstart = argv[0];
  for (i = 0; i < argc; ++i) {
  if (argv[i] > argvend || argv[i] < argvstart)
  break; /* not continuous */



To: spectral, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D6866: osutil: tolerate Py_GetArgcArgv not being set up properly

martinvonz (Martin von Zweigbergk)
Closed by commit rHGd6227c6c0814: osutil: tolerate Py_GetArgcArgv not being set up properly (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6866?vs=16577&id=16591

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6866/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6866

AFFECTED FILES
  mercurial/cext/osutil.c

CHANGE DETAILS

diff --git a/mercurial/cext/osutil.c b/mercurial/cext/osutil.c
--- a/mercurial/cext/osutil.c
+++ b/mercurial/cext/osutil.c
@@ -798,10 +798,17 @@
  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. */
- argvend = argvstart = argv[0];
  for (i = 0; i < argc; ++i) {
  if (argv[i] > argvend || argv[i] < argvstart)
  break; /* not continuous */



To: spectral, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel