]> git.videolan.org Git - x264.git/commitdiff
Error out on invalid input stride
authorJason Garrett-Glaser <darkshikari@gmail.com>
Sun, 2 May 2010 02:32:01 +0000 (19:32 -0700)
committerJason Garrett-Glaser <darkshikari@gmail.com>
Thu, 6 May 2010 05:08:23 +0000 (22:08 -0700)
Might catch some crashes due to buggy calling applications.

common/frame.c

index fa8eec0214231900e4acba85326e130e1f37c09f..66ebee8f1cd07cfe647713a4582d971b18933ae0 100644 (file)
@@ -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;