From ccc03ec16125e0586231afbb06936bd0bf8c926d Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Sat, 1 May 2010 19:32:01 -0700 Subject: [PATCH] Error out on invalid input stride Might catch some crashes due to buggy calling applications. --- common/frame.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; -- 2.47.3