Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 524f103

Browse files
author
Hirokazu Yamamoto
committed
Should call Py_INCREF for Py_None (Modules/_ssl.c: PySSL_cipher)
1 parent e239d23 commit 524f103

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Modules/_ssl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,17 +928,18 @@ static PyObject *PySSL_cipher (PySSLSocket *self) {
928928
char *cipher_protocol;
929929

930930
if (self->ssl == NULL)
931-
return Py_None;
931+
Py_RETURN_NONE;
932932
current = SSL_get_current_cipher(self->ssl);
933933
if (current == NULL)
934-
return Py_None;
934+
Py_RETURN_NONE;
935935

936936
retval = PyTuple_New(3);
937937
if (retval == NULL)
938938
return NULL;
939939

940940
cipher_name = (char *) SSL_CIPHER_get_name(current);
941941
if (cipher_name == NULL) {
942+
Py_INCREF(Py_None);
942943
PyTuple_SET_ITEM(retval, 0, Py_None);
943944
} else {
944945
v = PyUnicode_FromString(cipher_name);
@@ -948,6 +949,7 @@ static PyObject *PySSL_cipher (PySSLSocket *self) {
948949
}
949950
cipher_protocol = SSL_CIPHER_get_version(current);
950951
if (cipher_protocol == NULL) {
952+
Py_INCREF(Py_None);
951953
PyTuple_SET_ITEM(retval, 1, Py_None);
952954
} else {
953955
v = PyUnicode_FromString(cipher_protocol);

0 commit comments

Comments
 (0)