@@ -1027,25 +1027,23 @@ _get_aia_uri(X509 *certificate, int nid) {
1027
1027
static PyObject *
1028
1028
_get_crl_dp (X509 * certificate ) {
1029
1029
STACK_OF (DIST_POINT ) * dps ;
1030
- int i , j , result ;
1031
- PyObject * lst ;
1030
+ int i , j ;
1031
+ PyObject * lst , * res = NULL ;
1032
1032
1033
1033
#if OPENSSL_VERSION_NUMBER < 0x10001000L
1034
- dps = X509_get_ext_d2i (certificate , NID_crl_distribution_points ,
1035
- NULL , NULL );
1034
+ dps = X509_get_ext_d2i (certificate , NID_crl_distribution_points , NULL , NULL );
1036
1035
#else
1037
1036
/* Calls x509v3_cache_extensions and sets up crldp */
1038
1037
X509_check_ca (certificate );
1039
1038
dps = certificate -> crldp ;
1040
1039
#endif
1041
1040
1042
- if (dps == NULL ) {
1041
+ if (dps == NULL )
1043
1042
return Py_None ;
1044
- }
1045
1043
1046
- if (( lst = PyList_New (0 )) == NULL ) {
1047
- return NULL ;
1048
- }
1044
+ lst = PyList_New (0 );
1045
+ if ( lst == NULL )
1046
+ goto done ;
1049
1047
1050
1048
for (i = 0 ; i < sk_DIST_POINT_num (dps ); i ++ ) {
1051
1049
DIST_POINT * dp ;
@@ -1058,6 +1056,7 @@ _get_crl_dp(X509 *certificate) {
1058
1056
GENERAL_NAME * gn ;
1059
1057
ASN1_IA5STRING * uri ;
1060
1058
PyObject * ouri ;
1059
+ int err ;
1061
1060
1062
1061
gn = sk_GENERAL_NAME_value (gns , j );
1063
1062
if (gn -> type != GEN_URI ) {
@@ -1066,28 +1065,25 @@ _get_crl_dp(X509 *certificate) {
1066
1065
uri = gn -> d .uniformResourceIdentifier ;
1067
1066
ouri = PyUnicode_FromStringAndSize ((char * )uri -> data ,
1068
1067
uri -> length );
1069
- if (ouri == NULL ) {
1070
- Py_DECREF (lst );
1071
- return NULL ;
1072
- }
1073
- result = PyList_Append (lst , ouri );
1068
+ if (ouri == NULL )
1069
+ goto done ;
1070
+
1071
+ err = PyList_Append (lst , ouri );
1074
1072
Py_DECREF (ouri );
1075
- if (result < 0 ) {
1076
- Py_DECREF (lst );
1077
- return NULL ;
1078
- }
1073
+ if (err < 0 )
1074
+ goto done ;
1079
1075
}
1080
1076
}
1081
- /* convert to tuple or None */
1082
- if ( PyList_Size ( lst ) == 0 ) {
1083
- Py_DECREF (lst );
1084
- return Py_None ;
1085
- } else {
1086
- PyObject * tup ;
1087
- tup = PyList_AsTuple ( lst );
1088
- Py_DECREF ( lst );
1089
- return tup ;
1090
- }
1077
+
1078
+ /* Convert to tuple. */
1079
+ res = ( PyList_GET_SIZE ( lst ) > 0 ) ? PyList_AsTuple (lst ) : Py_None ;
1080
+
1081
+ done :
1082
+ Py_XDECREF ( lst ) ;
1083
+ #if OPENSSL_VERSION_NUMBER < 0x10001000L
1084
+ sk_DIST_POINT_free ( dsp );
1085
+ #endif
1086
+ return res ;
1091
1087
}
1092
1088
1093
1089
static PyObject *
0 commit comments