Commit 6f82bffd authored by Alexey Izbyshev's avatar Alexey Izbyshev Committed by Berker Peksag

bpo-34649: Add missing NULL checks to _encoded_const() (GH-9225)

Reported by Svace static analyzer.
parent 0dd71807
...@@ -1374,7 +1374,7 @@ _encoded_const(PyObject *obj) ...@@ -1374,7 +1374,7 @@ _encoded_const(PyObject *obj)
if (s_null == NULL) { if (s_null == NULL) {
s_null = PyUnicode_InternFromString("null"); s_null = PyUnicode_InternFromString("null");
} }
Py_INCREF(s_null); Py_XINCREF(s_null);
return s_null; return s_null;
} }
else if (obj == Py_True) { else if (obj == Py_True) {
...@@ -1382,7 +1382,7 @@ _encoded_const(PyObject *obj) ...@@ -1382,7 +1382,7 @@ _encoded_const(PyObject *obj)
if (s_true == NULL) { if (s_true == NULL) {
s_true = PyUnicode_InternFromString("true"); s_true = PyUnicode_InternFromString("true");
} }
Py_INCREF(s_true); Py_XINCREF(s_true);
return s_true; return s_true;
} }
else if (obj == Py_False) { else if (obj == Py_False) {
...@@ -1390,7 +1390,7 @@ _encoded_const(PyObject *obj) ...@@ -1390,7 +1390,7 @@ _encoded_const(PyObject *obj)
if (s_false == NULL) { if (s_false == NULL) {
s_false = PyUnicode_InternFromString("false"); s_false = PyUnicode_InternFromString("false");
} }
Py_INCREF(s_false); Py_XINCREF(s_false);
return s_false; return s_false;
} }
else { else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment