Should call Py_INCREF for Py_None (Modules/_ssl.c: PySSL_cipher)
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Thu, 9 Dec 2010 10:49:00 +0000 (10:49 +0000)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Thu, 9 Dec 2010 10:49:00 +0000 (10:49 +0000)
Modules/_ssl.c

index a5145552e8429a018ab72cb545aae0b507652d17..1e4b38a9cd88ac2a12e997272df86b65308bd08b 100644 (file)
@@ -928,10 +928,10 @@ static PyObject *PySSL_cipher (PySSLSocket *self) {
     char *cipher_protocol;
 
     if (self->ssl == NULL)
-        return Py_None;
+        Py_RETURN_NONE;
     current = SSL_get_current_cipher(self->ssl);
     if (current == NULL)
-        return Py_None;
+        Py_RETURN_NONE;
 
     retval = PyTuple_New(3);
     if (retval == NULL)
@@ -939,6 +939,7 @@ static PyObject *PySSL_cipher (PySSLSocket *self) {
 
     cipher_name = (char *) SSL_CIPHER_get_name(current);
     if (cipher_name == NULL) {
+        Py_INCREF(Py_None);
         PyTuple_SET_ITEM(retval, 0, Py_None);
     } else {
         v = PyUnicode_FromString(cipher_name);
@@ -948,6 +949,7 @@ static PyObject *PySSL_cipher (PySSLSocket *self) {
     }
     cipher_protocol = SSL_CIPHER_get_version(current);
     if (cipher_protocol == NULL) {
+        Py_INCREF(Py_None);
         PyTuple_SET_ITEM(retval, 1, Py_None);
     } else {
         v = PyUnicode_FromString(cipher_protocol);