2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 16:32:16 +00:00

-fix: boost::python::exec_file completely broken when PY_VERSION_HEX >= 0x03010000. Bug: char* f pointed to a temporary buffer returned by PyBytes_AsString. This buffer was released when Py_DECREF(fb) was called. As a result, f pointed to invalid memory when being passed to Py_RunFile.

This commit is contained in:
Hajo Kirchhoff
2021-08-10 13:23:18 +02:00
committed by Stefan Seefeld
parent 8dd1511773
commit a060d43bf2

View File

@@ -109,8 +109,8 @@ object BOOST_PYTHON_DECL exec_file(char const *filename, object global, object l
PyObject *fo = Py_BuildValue("s", f);
PyObject *fb = Py_None;
PyUnicode_FSConverter(fo, &fb);
f = PyBytes_AsString(fb);
FILE *fs = fopen(f, "r");
char *f_as_uft = PyBytes_AsString(fb);
FILE *fs = fopen(f_as_uft, "r");
Py_DECREF(fo);
Py_DECREF(fb);
#elif PY_VERSION_HEX >= 0x03000000