From f62dbc15bdddf355b18a4c150f627c4902919362 Mon Sep 17 00:00:00 2001 From: Luke Lovett Date: Wed, 22 Jul 2015 16:35:17 -0700 Subject: [PATCH] PYTHON-969 - Check return value from PyObject_Call before using it in PyObject_GetAttrString. --- bson/_cbsonmodule.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bson/_cbsonmodule.c b/bson/_cbsonmodule.c index 5f37c278a..d762cfd67 100644 --- a/bson/_cbsonmodule.c +++ b/bson/_cbsonmodule.c @@ -1912,6 +1912,12 @@ static PyObject* get_value(PyObject* self, const char* buffer, } Py_XDECREF(utc_type); value = PyObject_Call(replace, args, kwargs); + if (!value) { + Py_DECREF(replace); + Py_DECREF(args); + Py_DECREF(kwargs); + goto invalid; + } /* convert to local time */ if (options->tzinfo != Py_None) {