summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2012-08-22 12:40:35 (GMT)
committerRonald Oussoren <ronaldoussoren@mac.com>2012-08-22 12:40:35 (GMT)
commit9bd9cd3fb996e580733d452d61aa59af01a84d93 (patch)
treebc12674696314cba9d3da8b386d27979e71b8313
parent6f69fb145fd1b59c434a2b88c7e8a21a6ca9a479 (diff)
parenteb61f8b3a726a8cd1ae3bc3794623e7fe4dd5703 (diff)
downloadcpython-9bd9cd3fb996e580733d452d61aa59af01a84d93.zip
cpython-9bd9cd3fb996e580733d452d61aa59af01a84d93.tar.gz
cpython-9bd9cd3fb996e580733d452d61aa59af01a84d93.tar.bz2
Fix for issue 15716: interpreter could crash when PYTHONEXECUTABLE was set on Mac OS X.
This is due to an off-by-one error: the allocated buffer didn't have room for a NUL character at the end of the mbstowcs result. (merge with 3.2)
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/main.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 4082507..ceab279 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ What's New in Python 3.3.0 Release Candidate 1?
Core and Builtins
-----------------
+- Issue #15761: Fix crash when PYTHONEXECUTABLE is set on Mac OS X.
+
- Issue #15726: Fix incorrect bounds checking in PyState_FindModule.
Patch by Robin Schreiber.
diff --git a/Modules/main.c b/Modules/main.c
index e86aa77..a16ce65 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -604,7 +604,7 @@ Py_Main(int argc, wchar_t **argv)
script. */
if ((p = Py_GETENV("PYTHONEXECUTABLE")) && *p != '\0') {
wchar_t* buffer;
- size_t len = strlen(p);
+ size_t len = strlen(p) + 1;
buffer = malloc(len * sizeof(wchar_t));
if (buffer == NULL) {