Mercurial > mplayer.hg
changeset 31895:c2ad4fe46a89
validate input data and linesizes
author | ramiro |
---|---|
date | Wed, 18 Aug 2010 19:37:37 +0000 |
parents | f48c518b2097 |
children | b5636b1d006c |
files | libswscale/swscale.c |
diffstat | 1 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libswscale/swscale.c Wed Aug 18 19:28:22 2010 +0000 +++ b/libswscale/swscale.c Wed Aug 18 19:37:37 2010 +0000 @@ -1827,6 +1827,21 @@ } } +static int check_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, + const int linesizes[4]) +{ + const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + int i; + + for (i = 0; i < 4; i++) { + int plane = desc->comp[i].plane; + if (!data[plane] || !linesizes[plane]) + return 0; + } + + return 1; +} + /** * swscale wrapper, so we don't need to export the SwsContext. * Assumes planar YUV to be in YUV order instead of YVU. @@ -1842,6 +1857,15 @@ if (srcSliceH == 0) return 0; + if (!check_image_pointers(src, c->srcFormat, srcStride)) { + av_log(c, AV_LOG_ERROR, "bad src image pointers\n"); + return 0; + } + if (!check_image_pointers(dst, c->dstFormat, dstStride)) { + av_log(c, AV_LOG_ERROR, "bad dst image pointers\n"); + return 0; + } + if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) { av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n"); return 0;