Update src/_webp.c

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
This commit is contained in:
Evan Miller 2024-02-07 20:20:27 -05:00 committed by GitHub
parent 469db5114c
commit c93b23239d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -448,18 +448,19 @@ PyObject *
_anim_decoder_get_next(PyObject *self) { _anim_decoder_get_next(PyObject *self) {
uint8_t *buf; uint8_t *buf;
int timestamp; int timestamp;
int ok;
PyObject *bytes; PyObject *bytes;
PyObject *ret; PyObject *ret;
ImagingSectionCookie cookie; ImagingSectionCookie cookie;
WebPAnimDecoderObject *decp = (WebPAnimDecoderObject *)self; WebPAnimDecoderObject *decp = (WebPAnimDecoderObject *)self;
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
if (!WebPAnimDecoderGetNext(decp->dec, &buf, &timestamp)) { ok = WebPAnimDecoderGetNext(decp->dec, &buf, &timestamp)
ImagingSectionLeave(&cookie); ImagingSectionLeave(&cookie);
if (!ok) {
PyErr_SetString(PyExc_OSError, "failed to read next frame"); PyErr_SetString(PyExc_OSError, "failed to read next frame");
return NULL; return NULL;
} }
ImagingSectionLeave(&cookie);
bytes = PyBytes_FromStringAndSize( bytes = PyBytes_FromStringAndSize(
(char *)buf, decp->info.canvas_width * 4 * decp->info.canvas_height); (char *)buf, decp->info.canvas_width * 4 * decp->info.canvas_height);