]> granicus.if.org Git - python/commitdiff
[3.6] _pickle: Fix whichmodule() (GH-3358) (#3361)
authorChristian Heimes <christian@python.org>
Wed, 6 Sep 2017 04:43:19 +0000 (21:43 -0700)
committerGitHub <noreply@github.com>
Wed, 6 Sep 2017 04:43:19 +0000 (21:43 -0700)
_PyUnicode_FromId() can return NULL: replace Py_INCREF() with
Py_XINCREF().

Fix coverity report: CID 1417269.
(cherry picked from commit af46eb8)

Modules/_pickle.c

index 920b46fc28595f1f1166ac7551ee64883c728869..ef0a03b107939f1161ffa6ace9467a8a79a32b6f 100644 (file)
@@ -1705,7 +1705,7 @@ whichmodule(PyObject *global, PyObject *dotted_path)
 
     /* If no module is found, use __main__. */
     module_name = _PyUnicode_FromId(&PyId___main__);
-    Py_INCREF(module_name);
+    Py_XINCREF(module_name);
     return module_name;
 }