Prevent null pointer dereference in decode_gif.

PiperOrigin-RevId: 231841542
This commit is contained in:
Mihai Maruseac 2019-01-31 13:23:48 -08:00 committed by TensorFlower Gardener
parent 983a547e85
commit e41cb124cd

View File

@ -140,6 +140,10 @@ uint8* Decode(const void* srcdata, int datasize,
ColorMapObject* color_map = this_image->ImageDesc.ColorMap
? this_image->ImageDesc.ColorMap
: gif_file->SColorMap;
if (color_map == nullptr) {
*error_string = strings::StrCat("missing color map for frame ", k);
return nullptr;
}
for (int i = imgTop; i < imgBottom; ++i) {
uint8* p_dst = this_dst + i * width * channel;