djvulibre-check-image-size.patch 658 B

1234567891011121314151617
  1. diff --git a/libdjvu/IW44Image.cpp b/libdjvu/IW44Image.cpp
  2. index e8d4b44..aa3d554 100644
  3. --- a/libdjvu/IW44Image.cpp
  4. +++ b/libdjvu/IW44Image.cpp
  5. @@ -678,7 +678,11 @@ IW44Image::Map::image(signed char *img8, int rowsize, int pixsep, int fast)
  6. size_t sz = bw * bh;
  7. if (sz / (size_t)bw != (size_t)bh) // multiplication overflow
  8. G_THROW("IW44Image: image size exceeds maximum (corrupted file?)");
  9. + if (sz == 0)
  10. + G_THROW("IW44Image: zero size image (corrupted file?)");
  11. GPBuffer<short> gdata16(data16,sz);
  12. + if (data16 == NULL)
  13. + G_THROW("IW44Image: unable to allocate image data");
  14. // Copy coefficients
  15. int i;
  16. short *p = data16;