Merge pull request #2521 from adw1n/master

Fix for issue #2514 - error handling mistake in _webp.c
This commit is contained in:
wiredfool 2017-05-13 14:24:51 +01:00 committed by GitHub
commit f6f30b1c13
2 changed files with 7 additions and 2 deletions

View File

@ -77,6 +77,11 @@ class TestFileWebp(PillowTestCase):
self.assertRaises(IOError, lambda: hopper("L").save(temp_file))
def test_WebPEncode_with_invalid_args(self):
self.assertRaises(TypeError, _webp.WebPEncode)
def test_WebPDecode_with_invalid_args(self):
self.assertRaises(TypeError, _webp.WebPDecode)
if __name__ == '__main__':
unittest.main()

View File

@ -29,7 +29,7 @@ PyObject* WebPEncode_wrapper(PyObject* self, PyObject* args)
if (!PyArg_ParseTuple(args, "s#iiifss#s#",
(char**)&rgb, &size, &width, &height, &lossless, &quality_factor, &mode,
&icc_bytes, &icc_size, &exif_bytes, &exif_size)) {
Py_RETURN_NONE;
return NULL;
}
if (strcmp(mode, "RGBA")==0){
if (size < width * height * 4){
@ -145,7 +145,7 @@ PyObject* WebPDecode_wrapper(PyObject* self, PyObject* args)
char* mode = "RGB";
if (!PyArg_ParseTuple(args, "S", &webp_string)) {
Py_RETURN_NONE;
return NULL;
}
if (!WebPInitDecoderConfig(&config)) {