From 97cb67b9ca1d3e36dcaabb3879380c01820e16a6 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sat, 20 Jul 2013 15:01:26 +0200 Subject: [PATCH] Add missing check of PyDict_SetItem()'s return value CID 486659 --- Modules/_testcapimodule.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 2f4381363a5..ab10faab00a 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -120,7 +120,10 @@ test_dict_inner(int count) for (i = 0; i < count; i++) { v = PyLong_FromLong(i); - PyDict_SetItem(dict, v, v); + if (PyDict_SetItem(dict, v, v) < 0) { + Py_DECREF(v); + return -1; + } Py_DECREF(v); }