Fix memory management vulnerabilities

This commit is contained in:
2025-07-03 19:53:00 +02:00
parent 2fcef1a0de
commit 91225207f2
7 changed files with 731 additions and 130 deletions

View File

@@ -237,12 +237,12 @@ namespace pywrap {
CPyObject method = PyUnicode_FromString(name.c_str());
try {
if (!(result = PyObject_CallMethodObjArgs(instance, method.getObject(), X.getObject(), NULL)))
errorAbort("Couldn't call method predict");
errorAbort("Couldn't call method " + name);
}
catch (const std::exception& e) {
errorAbort(e.what());
}
Py_INCREF(result);
// PyObject_CallMethodObjArgs already returns a new reference, no need for Py_INCREF
return result; // Caller must free this object
}
double PyWrap::score(const clfId_t id, CPyObject& X, CPyObject& y)