Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.

Patch by Serhiy Storchaka.
This commit is contained in:
Antoine Pitrou 2012-08-15 23:18:25 +02:00
parent dd7c55250d
commit 6f430e4963
11 changed files with 87 additions and 39 deletions

View file

@ -883,6 +883,7 @@ PySSL_peercert(PySSLSocket *self, PyObject *args)
int len;
int verification;
PyObject *binary_mode = Py_None;
int b;
if (!PyArg_ParseTuple(args, "|O:peer_certificate", &binary_mode))
return NULL;
@ -890,7 +891,10 @@ PySSL_peercert(PySSLSocket *self, PyObject *args)
if (!self->peer_cert)
Py_RETURN_NONE;
if (PyObject_IsTrue(binary_mode)) {
b = PyObject_IsTrue(binary_mode);
if (b < 0)
return NULL;
if (b) {
/* return cert in DER-encoded format */
unsigned char *bytes_buf = NULL;