From 1c3d937bcbc8faf02066d8805659062fc91a8384 Mon Sep 17 00:00:00 2001 From: Edgar Ellis Date: Mon, 10 Apr 2017 15:09:23 -0300 Subject: [PATCH] Check for fopen failure in exec_file At least in python 3.4.6 passing a NULL file pointer to PyRun_File results in reading uninitialized memory. --- src/exec.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/exec.cpp b/src/exec.cpp index fa2860e40..b1b4f9223 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -97,6 +97,7 @@ object BOOST_PYTHON_DECL exec_file(str filename, object global, object local) python::handle<> file(pyfile); FILE *fs = PyFile_AsFile(file.get()); #endif + if (!fs) throw std::invalid_argument(std::string(f) + " : no such file"); PyObject* result = PyRun_File(fs, f, Py_file_input,