On Sat, 24 Sep 2011 13:08:43 +0400, Vadim Girlin <vadimgir...@gmail.com> wrote:
> ---
>  src/mesa/main/api_validate.c |    9 ++++++---
>  1 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
> index 1fcf5cd..9338f4c 100644
> --- a/src/mesa/main/api_validate.c
> +++ b/src/mesa/main/api_validate.c
> @@ -257,7 +257,8 @@ _mesa_validate_DrawElements(struct gl_context *ctx,
>     if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
>        /* use indices in the buffer object */
>        /* make sure count doesn't go outside buffer bounds */
> -      if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) 
> {
> +      GLbyte * indices_end = (GLbyte*)indices + index_bytes(type, count);
> +      if (indices_end > (GLbyte*)ctx->Array.ElementArrayBufferObj->Size) {
>           _mesa_warning(ctx, "glDrawElements index out of buffer bounds");
>           return GL_FALSE;
>        }
> @@ -318,7 +319,8 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, 
> GLenum mode,
>     if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
>        /* use indices in the buffer object */
>        /* make sure count doesn't go outside buffer bounds */
> -      if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) 
> {
> +      GLbyte * indices_end = (GLbyte*)indices + index_bytes(type, count);
> +      if (indices_end > (GLbyte*)ctx->Array.ElementArrayBufferObj->Size) {
>           _mesa_warning(ctx, "glDrawRangeElements index out of buffer 
> bounds");
>           return GL_FALSE;
>        }
> @@ -457,7 +459,8 @@ _mesa_validate_DrawElementsInstanced(struct gl_context 
> *ctx,
>     if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
>        /* use indices in the buffer object */
>        /* make sure count doesn't go outside buffer bounds */
> -      if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) 
> {
> +      GLbyte * indices_end = (GLbyte*)indices + index_bytes(type, count);
> +      if (indices_end > (GLbyte*)ctx->Array.ElementArrayBufferObj->Size) {
>           _mesa_warning(ctx,
>                         "glDrawElementsInstanced index out of buffer bounds");
>           return GL_FALSE;

This index buffer checking really looks like it should be in a separate
helper function.

Attachment: pgpIICzVmAnaT.pgp
Description: PGP signature

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to