From e98ccf66902f10ce2daaa33a22fb8ee8d99de18f Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Thu, 23 Mar 2006 05:39:47 +0000 Subject: Forward port MvL's fix in 43227: Fix crash when a Unicode string containing an encoding declaration is compile()d. Fixes #1115379. --- Python/ast.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Python/ast.c') diff --git a/Python/ast.c b/Python/ast.c index 3c339f000e..30275a6d40 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -191,6 +191,10 @@ PyAST_FromNode(const node *n, PyCompilerFlags *flags, const char *filename, if (flags && flags->cf_flags & PyCF_SOURCE_IS_UTF8) { c.c_encoding = "utf-8"; + if (TYPE(n) == encoding_decl) { + ast_error(n, "encoding declaration in Unicode string"); + goto error; + } } else if (TYPE(n) == encoding_decl) { c.c_encoding = STR(n); n = CHILD(n, 0); -- cgit v1.2.1