]> granicus.if.org Git - python/commitdiff
Fix for issue 15716: interpreter could crash when PYTHONEXECUTABLE was set on Mac...
authorRonald Oussoren <ronaldoussoren@mac.com>
Wed, 22 Aug 2012 12:24:14 +0000 (14:24 +0200)
committerRonald Oussoren <ronaldoussoren@mac.com>
Wed, 22 Aug 2012 12:24:14 +0000 (14:24 +0200)
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.

Misc/NEWS
Modules/main.c

index 87a89fbbc1d242cc6f609d8af0e4bf69a013590b..a9c96950f80e0b6112d9a5cf1d51e5fc747f0d1a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ What's New in Python 3.2.4
 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.
 
index 5b4a7e2e64f18b0d5ae5d848f7349786067b888a..5d1d8964bfd59d23c29f4cb225c738026522792d 100644 (file)
@@ -616,7 +616,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;
         size_t r;
 
         buffer = malloc(len * sizeof(wchar_t));