mp_image: reject 0-sized images

Like FFmpeg/Libav do. It seems not all code can actually deal with this
situation, so it's better to shift the special-cases to code which needs
it (possibly OSD code; screenshots of 0x0 windows would just fail).
This commit is contained in:
wm4 2015-03-23 18:38:19 +01:00
parent cfb5e0cea6
commit e52f7d3da8
1 changed files with 1 additions and 2 deletions

View File

@ -473,8 +473,7 @@ bool mp_image_params_valid(const struct mp_image_params *p)
// ints. We also should (for now) do the same as FFmpeg, to be sure large
// images don't crash with libswscale or when wrapping with AVFrame and
// passing the result to filters.
// Unlike FFmpeg, consider 0x0 valid (might be needed for OSD/screenshots).
if (p->w < 0 || p->h < 0 || (p->w + 128LL) * (p->h + 128LL) >= INT_MAX / 8)
if (p->w <= 0 || p->h <= 0 || (p->w + 128LL) * (p->h + 128LL) >= INT_MAX / 8)
return false;
if (p->d_w <= 0 || p->d_h <= 0)