Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e132f52

Browse files
committed
check return value of _PyUnicode_AsString
1 parent 591c921 commit e132f52

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Python/symtable.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,12 +1202,14 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
12021202
asdl_seq *seq = s->v.Global.names;
12031203
for (i = 0; i < asdl_seq_LEN(seq); i++) {
12041204
identifier name = (identifier)asdl_seq_GET(seq, i);
1205-
char *c_name = _PyUnicode_AsString(name);
12061205
long cur = symtable_lookup(st, name);
12071206
if (cur < 0)
12081207
return 0;
12091208
if (cur & (DEF_LOCAL | USE)) {
12101209
char buf[256];
1210+
char *c_name = _PyUnicode_AsString(name);
1211+
if (!c_name)
1212+
return 0;
12111213
if (cur & DEF_LOCAL)
12121214
PyOS_snprintf(buf, sizeof(buf),
12131215
GLOBAL_AFTER_ASSIGN,
@@ -1229,12 +1231,14 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
12291231
asdl_seq *seq = s->v.Nonlocal.names;
12301232
for (i = 0; i < asdl_seq_LEN(seq); i++) {
12311233
identifier name = (identifier)asdl_seq_GET(seq, i);
1232-
char *c_name = _PyUnicode_AsString(name);
12331234
long cur = symtable_lookup(st, name);
12341235
if (cur < 0)
12351236
return 0;
12361237
if (cur & (DEF_LOCAL | USE)) {
12371238
char buf[256];
1239+
char *c_name = _PyUnicode_AsString(name);
1240+
if (!c_name)
1241+
return 0;
12381242
if (cur & DEF_LOCAL)
12391243
PyOS_snprintf(buf, sizeof(buf),
12401244
NONLOCAL_AFTER_ASSIGN,

0 commit comments

Comments
 (0)