From 49bf3e8265d2c7c54e55a62f46251a81b4861ad4 Mon Sep 17 00:00:00 2001 From: Francois Keith <keith@lirmm.fr> Date: Sat, 15 Mar 2014 01:00:22 +0100 Subject: [PATCH] Avoid memory leak. --- src/interpreter.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/interpreter.cc b/src/interpreter.cc index 33ebe62..9f1e2e5 100644 --- a/src/interpreter.cc +++ b/src/interpreter.cc @@ -230,13 +230,14 @@ PyObject* Interpreter::globals() void Interpreter::runPythonFile( std::string filename ) { PyObject* pymainContext = globals_; - PyRun_FileExFlags(fopen( filename.c_str(),"r" ), filename.c_str(), + PyObject* run = PyRun_FileExFlags(fopen( filename.c_str(),"r" ), filename.c_str(), Py_file_input, pymainContext,pymainContext, true, NULL); if (PyErr_Occurred()) { std::cout << "Error occures..." << std::endl; PyErr_Print(); } + Py_DecRef(run); } void Interpreter::runMain( void ) -- GitLab