From: Jason Garrett-Glaser Date: Sun, 2 May 2010 02:32:01 +0000 (-0700) Subject: Error out on invalid input stride X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=ccc03ec16125e0586231afbb06936bd0bf8c926d;p=x264.git Error out on invalid input stride Might catch some crashes due to buggy calling applications. --- diff --git a/common/frame.c b/common/frame.c index fa8eec02..66ebee8f 100644 --- a/common/frame.c +++ b/common/frame.c @@ -219,7 +219,7 @@ int x264_frame_copy_picture( x264_t *h, x264_frame_t *dst, x264_picture_t *src ) int i_csp = src->img.i_csp & X264_CSP_MASK; if( i_csp != X264_CSP_I420 && i_csp != X264_CSP_YV12 ) { - x264_log( h, X264_LOG_ERROR, "Arg invalid CSP\n" ); + x264_log( h, X264_LOG_ERROR, "Invalid input colorspace\n" ); return -1; } @@ -241,6 +241,11 @@ int x264_frame_copy_picture( x264_t *h, x264_frame_t *dst, x264_picture_t *src ) plane += (height-1)*stride; stride = -stride; } + if( width > abs(stride) ) + { + x264_log( h, X264_LOG_ERROR, "Input picture width is greater than stride\n" ); + return -1; + } h->mc.plane_copy( dst->plane[i], dst->i_stride[i], plane, stride, width, height ); } return 0;