WebPPictureImport*: check output pointer

fixes crash with NULL output pointer in calls to simple encode api
(WebPEncodeRGB, etc.)

Change-Id: I91e7a1c0e070ea842b0a2a4ac54e981cac8629bf
This commit is contained in:
James Zern 2016-03-25 18:21:13 -07:00
parent c07687699b
commit ec1b2407a4

View File

@ -237,6 +237,8 @@ static size_t Encode(const uint8_t* rgba, int width, int height, int stride,
WebPMemoryWriter wrt; WebPMemoryWriter wrt;
int ok; int ok;
if (output == NULL) return 0;
if (!WebPConfigPreset(&config, WEBP_PRESET_DEFAULT, quality_factor) || if (!WebPConfigPreset(&config, WEBP_PRESET_DEFAULT, quality_factor) ||
!WebPPictureInit(&pic)) { !WebPPictureInit(&pic)) {
return 0; // shouldn't happen, except if system installation is broken return 0; // shouldn't happen, except if system installation is broken