*/
PyObject *next_input = dec_buffer;
PyBytes_Concat(&next_input, input_chunk);
+ dec_buffer = NULL; /* Reference lost to PyBytes_Concat */
if (next_input == NULL) {
- dec_buffer = NULL; /* Reference lost to PyBytes_Concat */
goto fail;
}
- Py_XSETREF(self->snapshot, Py_BuildValue("NN", dec_flags, next_input));
+ PyObject *snapshot = Py_BuildValue("NN", dec_flags, next_input);
+ if (snapshot == NULL) {
+ dec_flags = NULL;
+ goto fail;
+ }
+ Py_XSETREF(self->snapshot, snapshot);
}
Py_DECREF(input_chunk);
cookie_type cookie;
PyObject *res;
int cmp;
+ PyObject *snapshot;
CHECK_ATTACHED(self);
CHECK_CLOSED(self);
goto fail;
}
- self->snapshot = Py_BuildValue("iN", cookie.dec_flags, input_chunk);
- if (self->snapshot == NULL) {
- Py_DECREF(input_chunk);
+ snapshot = Py_BuildValue("iN", cookie.dec_flags, input_chunk);
+ if (snapshot == NULL) {
goto fail;
}
+ Py_XSETREF(self->snapshot, snapshot);
decoded = _PyObject_CallMethodId(self->decoder, &PyId_decode,
"Oi", input_chunk, (int)cookie.need_eof);
self->decoded_chars_used = cookie.chars_to_skip;
}
else {
- self->snapshot = Py_BuildValue("iy", cookie.dec_flags, "");
- if (self->snapshot == NULL)
+ snapshot = Py_BuildValue("iy", cookie.dec_flags, "");
+ if (snapshot == NULL)
goto fail;
+ Py_XSETREF(self->snapshot, snapshot);
}
/* Finally, reset the encoder (merely useful for proper BOM handling) */