Skip to content

Commit 39cdf20

Browse files
committed
Handle error, fix leaked ref
1 parent de883a5 commit 39cdf20

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

Parser/asdl_c.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -923,13 +923,20 @@ def visitModule(self, mod):
923923
fmt = "'%U', ";
924924
}
925925
num_left--;
926-
PyObject *tmp = PyUnicode_FromFormat(fmt, name);
927-
if (!tmp) {
926+
PyObject *tail = PyUnicode_FromFormat(fmt, name);
927+
if (!tail) {
928928
Py_DECREF(name_str);
929929
Py_DECREF(name);
930930
return NULL;
931931
}
932-
name_str = PyUnicode_Concat(name_str, tmp);
932+
PyObject *tmp = PyUnicode_Concat(name_str, tail);
933+
Py_DECREF(name_str);
934+
Py_DECREF(tail);
935+
if (!tmp) {
936+
Py_DECREF(name);
937+
return NULL;
938+
}
939+
name_str = tmp;
933940
}
934941
Py_DECREF(name);
935942
}

Python/Python-ast.c

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)