Closed
Description
Bug report
Lines 255 to 273 in c085974
If Py_SetPythonHome
was called with a non-empty string and is subsequently called with an empty one, it will always run PyMem_RawFree
but only actually reset the pointer in .home
if has_value
is set, so if home && home[0]
(i.e. non-empty string).
Minimal example:
Py_SetPythonHome(L"/non-empty");
Py_SetPythonHome(L"");
// After this, the memory region in .home is freed but the pointer is not overwritten
Your environment
The issue occurs in our (Python.NET) test-suite: pythonnet/pythonnet#1955
- CPython versions tested on: 3.7 - 3.11, only occurs in 3.11
- Operating system and architecture: Windows (x86, amd64), macOS (amd64), Linux (amd64)
Additional notes
This bug was introduced in #29041, in the initial commit: a63f5d8
It's a regression, the first faulty version was 3.11.0a3.