[Python-checkins] bpo-37072: Fix crash in PyAST_FromNodeObject() when flags is NULL (#13634)

Guido van Rossum webhook-mailer at python.org
Tue May 28 19:45:02 EDT 2019


https://github.com/python/cpython/commit/77f0ed7a42606d03ebfe48ab152caf0d796d6540
commit: 77f0ed7a42606d03ebfe48ab152caf0d796d6540
branch: master
author: Guido van Rossum <guido at python.org>
committer: GitHub <noreply at github.com>
date: 2019-05-28T16:44:58-07:00
summary:

bpo-37072: Fix crash in PyAST_FromNodeObject() when flags is NULL (#13634)

I'm confident that this fixes the reported crash. flags=NULL is treated as using the latest minor version.

https://bugs.python.org/issue37072

files:
A Misc/NEWS.d/next/Core and Builtins/2019-05-28-18-18-55.bpo-37072.1Hewl3.rst
M Python/ast.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-05-28-18-18-55.bpo-37072.1Hewl3.rst b/Misc/NEWS.d/next/Core and Builtins/2019-05-28-18-18-55.bpo-37072.1Hewl3.rst
new file mode 100644
index 000000000000..15bcc5ed2bb0
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2019-05-28-18-18-55.bpo-37072.1Hewl3.rst	
@@ -0,0 +1 @@
+Fix crash in PyAST_FromNodeObject() when flags is NULL.
\ No newline at end of file
diff --git a/Python/ast.c b/Python/ast.c
index 7ffdf4a2a037..12a45f9bbb00 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -786,7 +786,7 @@ PyAST_FromNodeObject(const node *n, PyCompilerFlags *flags,
     /* borrowed reference */
     c.c_filename = filename;
     c.c_normalize = NULL;
-    c.c_feature_version = flags->cf_feature_version;
+    c.c_feature_version = flags ? flags->cf_feature_version : PY_MINOR_VERSION;
 
     if (TYPE(n) == encoding_decl)
         n = CHILD(n, 0);



More information about the Python-checkins mailing list