mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-29 10:13:09 +03:00
webp: better error checking when using Mux API
This commit is contained in:
parent
fef9c7001d
commit
76bafe20a6
18
_webp.c
18
_webp.c
|
@ -173,21 +173,25 @@ PyObject* WebPDecode_wrapper(PyObject* self, PyObject* args)
|
||||||
WebPData exif_data = {0};
|
WebPData exif_data = {0};
|
||||||
|
|
||||||
WebPMux* mux = WebPMuxCreate(&data, copy_data);
|
WebPMux* mux = WebPMuxCreate(&data, copy_data);
|
||||||
WebPMuxGetFrame(mux, 1, &image);
|
if (NULL == mux)
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
if (WEBP_MUX_OK != WebPMuxGetFrame(mux, 1, &image))
|
||||||
|
{
|
||||||
|
WebPMuxDelete(mux);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
webp = image.bitstream.bytes;
|
webp = image.bitstream.bytes;
|
||||||
size = image.bitstream.size;
|
size = image.bitstream.size;
|
||||||
|
|
||||||
vp8_status_code = WebPDecode(webp, size, &config);
|
vp8_status_code = WebPDecode(webp, size, &config);
|
||||||
|
|
||||||
WebPMuxGetChunk(mux, "ICCP", &icc_profile_data);
|
if (WEBP_MUX_OK == WebPMuxGetChunk(mux, "ICCP", &icc_profile_data))
|
||||||
if (icc_profile_data.size > 0) {
|
|
||||||
icc_profile = PyBytes_FromStringAndSize((const char*)icc_profile_data.bytes, icc_profile_data.size);
|
icc_profile = PyBytes_FromStringAndSize((const char*)icc_profile_data.bytes, icc_profile_data.size);
|
||||||
}
|
|
||||||
|
|
||||||
WebPMuxGetChunk(mux, "EXIF", &exif_data);
|
if (WEBP_MUX_OK == WebPMuxGetChunk(mux, "EXIF", &exif_data))
|
||||||
if (exif_data.size > 0) {
|
|
||||||
exif = PyBytes_FromStringAndSize((const char*)exif_data.bytes, exif_data.size);
|
exif = PyBytes_FromStringAndSize((const char*)exif_data.bytes, exif_data.size);
|
||||||
}
|
|
||||||
|
|
||||||
WebPDataClear(&image.bitstream);
|
WebPDataClear(&image.bitstream);
|
||||||
WebPMuxDelete(mux);
|
WebPMuxDelete(mux);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user