diff options
author | Brian Paul <[email protected]> | 2002-01-15 21:49:57 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2002-01-15 21:49:57 +0000 |
commit | 858b694b6478c0139fbe4a6da16fc97d99fcf5c4 (patch) | |
tree | e012f11b5ca44589698d97b4a733ff61643d9249 | |
parent | 25c5f1b448bc45e10bfbcfbfa816239ab809cdab (diff) |
added some missing error checks
-rw-r--r-- | src/mesa/main/drawpix.c | 19 | ||||
-rw-r--r-- | src/mesa/swrast/s_drawpix.c | 7 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c index ac1c68af5ed..9f2047878af 100644 --- a/src/mesa/main/drawpix.c +++ b/src/mesa/main/drawpix.c @@ -1,10 +1,10 @@ -/* $Id: drawpix.c,v 1.58 2001/12/14 02:55:08 brianp Exp $ */ +/* $Id: drawpix.c,v 1.59 2002/01/15 21:49:57 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -52,6 +52,11 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + if (width < 0 || height < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glDrawPixels(width or height < 0" ); + return; + } + if (ctx->RenderMode==GL_RENDER) { GLint x, y; if (!pixels || !ctx->Current.RasterPosValid) { @@ -98,6 +103,11 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + if (width < 0 || height < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glReadPixels(width or height < 0)" ); + return; + } + if (!pixels) { _mesa_error( ctx, GL_INVALID_VALUE, "glReadPixels(pixels)" ); return; @@ -122,7 +132,7 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (width < 0 || height < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glCopyPixels" ); + _mesa_error( ctx, GL_INVALID_VALUE, "glCopyPixels(width or height < 0)" ); return; } @@ -171,9 +181,8 @@ _mesa_Bitmap( GLsizei width, GLsizei height, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - /* Error checking */ if (width < 0 || height < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glBitmap" ); + _mesa_error( ctx, GL_INVALID_VALUE, "glBitmap(width or height < 0)" ); return; } diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index b3a4a7886df..dfe71668802 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -1,4 +1,4 @@ -/* $Id: s_drawpix.c,v 1.24 2002/01/10 16:54:29 brianp Exp $ */ +/* $Id: s_drawpix.c,v 1.25 2002/01/15 21:49:58 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -560,6 +560,11 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y, return; } + if (ctx->Visual.stencilBits == 0) { + _mesa_error( ctx, GL_INVALID_OPERATION, "glDrawPixels(no stencil buffer)"); + return; + } + drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width; for (row = 0; row < height; row++, y++) { |