]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-34649: Add missing NULL checks to _encoded_const() (GH-9225)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 12 Sep 2018 22:00:11 +0000 (15:00 -0700)
committerBerker Peksag <berker.peksag@gmail.com>
Wed, 12 Sep 2018 22:00:11 +0000 (01:00 +0300)
Reported by Svace static analyzer.
(cherry picked from commit 6f82bffd2df63a4072b3f0483cdbe93ddedb87e9)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
Modules/_json.c

index 8f1743bada875394a950de4ce871b0cc603c7999..dad6b01f822fa2d63b5c1082796340877fb4c80a 100644 (file)
@@ -1376,7 +1376,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) {
@@ -1384,7 +1384,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) {
@@ -1392,7 +1392,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 {