File tree 1 file changed +15
-13
lines changed
1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -121,33 +121,35 @@ conn_encode(connectionObject *self, PyObject *u)
121
121
PyObject *
122
122
conn_decode (connectionObject * self , const char * str , Py_ssize_t len )
123
123
{
124
- PyObject * b = NULL ;
125
- PyObject * t = NULL ;
126
- PyObject * rv = NULL ;
127
-
128
124
if (len < 0 ) { len = strlen (str ); }
129
125
130
126
if (self ) {
131
127
if (self -> cdecoder ) {
132
128
return self -> cdecoder (str , len , NULL );
133
129
}
134
130
else if (self -> pydecoder ) {
135
- if (!(b = Bytes_FromStringAndSize (str , len ))) { goto exit ; }
131
+ PyObject * b = NULL ;
132
+ PyObject * t = NULL ;
133
+ PyObject * rv = NULL ;
134
+
135
+ if (!(b = Bytes_FromStringAndSize (str , len ))) { goto error ; }
136
136
if (!(t = PyObject_CallFunctionObjArgs (self -> pydecoder , b , NULL ))) {
137
- goto exit ;
137
+ goto error ;
138
138
}
139
- rv = PyTuple_GetItem (t , 0 );
140
- Py_XINCREF (rv );
139
+ if (!(rv = PyTuple_GetItem (t , 0 ))) { goto error ; }
140
+ Py_INCREF (rv ); /* PyTuple_GetItem gives a borrowes one */
141
+ error :
142
+ Py_XDECREF (t );
143
+ Py_XDECREF (b );
144
+ return rv ;
145
+ }
146
+ else {
147
+ return PyUnicode_FromStringAndSize (str , len );
141
148
}
142
149
}
143
150
else {
144
151
return PyUnicode_FromStringAndSize (str , len );
145
152
}
146
-
147
- exit :
148
- Py_XDECREF (t );
149
- Py_XDECREF (b );
150
- return rv ;
151
153
}
152
154
153
155
/* conn_notice_callback - process notices */
You can’t perform that action at this time.
0 commit comments