summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-10-31 23:01:42 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-10-31 23:01:42 (GMT)
commite132f527c9ae1e6b375a39014563015c6391f52f (patch)
tree8bce42397ae7a0f7f1087ebf77398d301ea054bb /Python
parent591c9214110d1004032c61b00e47ad0805947ef2 (diff)
downloadcpython-e132f527c9ae1e6b375a39014563015c6391f52f.zip
cpython-e132f527c9ae1e6b375a39014563015c6391f52f.tar.gz
cpython-e132f527c9ae1e6b375a39014563015c6391f52f.tar.bz2
check return value of _PyUnicode_AsString
Diffstat (limited to 'Python')
-rw-r--r--Python/symtable.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/symtable.c b/Python/symtable.c
index 1c291bb..ff6e8b7 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -1202,12 +1202,14 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
asdl_seq *seq = s->v.Global.names;
for (i = 0; i < asdl_seq_LEN(seq); i++) {
identifier name = (identifier)asdl_seq_GET(seq, i);
- char *c_name = _PyUnicode_AsString(name);
long cur = symtable_lookup(st, name);
if (cur < 0)
return 0;
if (cur & (DEF_LOCAL | USE)) {
char buf[256];
+ char *c_name = _PyUnicode_AsString(name);
+ if (!c_name)
+ return 0;
if (cur & DEF_LOCAL)
PyOS_snprintf(buf, sizeof(buf),
GLOBAL_AFTER_ASSIGN,
@@ -1229,12 +1231,14 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
asdl_seq *seq = s->v.Nonlocal.names;
for (i = 0; i < asdl_seq_LEN(seq); i++) {
identifier name = (identifier)asdl_seq_GET(seq, i);
- char *c_name = _PyUnicode_AsString(name);
long cur = symtable_lookup(st, name);
if (cur < 0)
return 0;
if (cur & (DEF_LOCAL | USE)) {
char buf[256];
+ char *c_name = _PyUnicode_AsString(name);
+ if (!c_name)
+ return 0;
if (cur & DEF_LOCAL)
PyOS_snprintf(buf, sizeof(buf),
NONLOCAL_AFTER_ASSIGN,