]> granicus.if.org Git - python/commitdiff
bpo-37072: Fix crash in PyAST_FromNodeObject() when flags is NULL (#13634)
authorGuido van Rossum <guido@python.org>
Tue, 28 May 2019 23:44:58 +0000 (16:44 -0700)
committerGitHub <noreply@github.com>
Tue, 28 May 2019 23:44:58 +0000 (16:44 -0700)
I'm confident that this fixes the reported crash. flags=NULL is treated as using the latest minor version.

https://bugs.python.org/issue37072

Misc/NEWS.d/next/Core and Builtins/2019-05-28-18-18-55.bpo-37072.1Hewl3.rst [new file with mode: 0644]
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 (file)
index 0000000..15bcc5e
--- /dev/null
@@ -0,0 +1 @@
+Fix crash in PyAST_FromNodeObject() when flags is NULL.
\ No newline at end of file
index 7ffdf4a2a03709225e405b22340cdf574bcda190..12a45f9bbb0074cb6cfc59d96b56bf442f5e3d83 100644 (file)
@@ -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);