gh-87092: do not allocate PyFutureFeatures dynamically (GH-98913)

This commit is contained in:
Irit Katriel 2022-11-02 15:13:07 +00:00 committed by GitHub
parent c76db37c0d
commit 6d683d8525
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 32 deletions

View file

@ -96,22 +96,14 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, PyObject *filename)
}
PyFutureFeatures *
_PyFuture_FromAST(mod_ty mod, PyObject *filename)
int
_PyFuture_FromAST(mod_ty mod, PyObject *filename, PyFutureFeatures *ff)
{
PyFutureFeatures *ff;
ff = (PyFutureFeatures *)PyObject_Malloc(sizeof(PyFutureFeatures));
if (ff == NULL) {
PyErr_NoMemory();
return NULL;
}
ff->ff_features = 0;
ff->ff_location = (_PyCompilerSrcLocation){-1, -1, -1, -1};
if (!future_parse(ff, mod, filename)) {
PyObject_Free(ff);
return NULL;
return 0;
}
return ff;
return 1;
}