File tree Expand file tree Collapse file tree 1 file changed +15
-13
lines changed
Expand file tree Collapse file tree 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)
121121PyObject *
122122conn_decode (connectionObject * self , const char * str , Py_ssize_t len )
123123{
124- PyObject * b = NULL ;
125- PyObject * t = NULL ;
126- PyObject * rv = NULL ;
127-
128124 if (len < 0 ) { len = strlen (str ); }
129125
130126 if (self ) {
131127 if (self -> cdecoder ) {
132128 return self -> cdecoder (str , len , NULL );
133129 }
134130 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 ; }
136136 if (!(t = PyObject_CallFunctionObjArgs (self -> pydecoder , b , NULL ))) {
137- goto exit ;
137+ goto error ;
138138 }
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 );
141148 }
142149 }
143150 else {
144151 return PyUnicode_FromStringAndSize (str , len );
145152 }
146-
147- exit :
148- Py_XDECREF (t );
149- Py_XDECREF (b );
150- return rv ;
151153}
152154
153155/* conn_notice_callback - process notices */
You can’t perform that action at this time.
0 commit comments