Check whether there are flags.
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 3cb03dc..2a6afe2 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1254,7 +1254,7 @@
                 PyArena_Free(arena);
 		return NULL;
         }
-	if (flags->cf_flags & PyCF_ONLY_AST) {
+	if (flags && (flags->cf_flags & PyCF_ONLY_AST)) {
 		PyObject *result = PyAST_mod2obj(mod);
 		PyArena_Free(arena);
 		return result;