]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-34649: Add missing NULL checks to _encoded_const() (GH-9225)
authorAlexey Izbyshev <izbyshev@ispras.ru>
Wed, 12 Sep 2018 21:05:20 +0000 (00:05 +0300)
committerBerker Peksag <berker.peksag@gmail.com>
Wed, 12 Sep 2018 21:05:20 +0000 (00:05 +0300)
Reported by Svace static analyzer.

Modules/_json.c

index 5a9464e34fb7f339d5f494cce00f8bf07a65c6b1..ac6e017a4eafc1430e65c387e05af45064ceb4de 100644 (file)
@@ -1374,7 +1374,7 @@ _encoded_const(PyObject *obj)
         if (s_null == NULL) {
             s_null = PyUnicode_InternFromString("null");
         }
-        Py_INCREF(s_null);
+        Py_XINCREF(s_null);
         return s_null;
     }
     else if (obj == Py_True) {
@@ -1382,7 +1382,7 @@ _encoded_const(PyObject *obj)
         if (s_true == NULL) {
             s_true = PyUnicode_InternFromString("true");
         }
-        Py_INCREF(s_true);
+        Py_XINCREF(s_true);
         return s_true;
     }
     else if (obj == Py_False) {
@@ -1390,7 +1390,7 @@ _encoded_const(PyObject *obj)
         if (s_false == NULL) {
             s_false = PyUnicode_InternFromString("false");
         }
-        Py_INCREF(s_false);
+        Py_XINCREF(s_false);
         return s_false;
     }
     else {