diff options
| author | Brian Paul <brian.paul@tungstengraphics.com> | 2006-05-05 14:49:38 +0000 | 
|---|---|---|
| committer | Brian Paul <brian.paul@tungstengraphics.com> | 2006-05-05 14:49:38 +0000 | 
| commit | 9b20b68af16af6bd630e9a5ed5b56fdf837fa29f (patch) | |
| tree | 84491d00a4aa641fc0301d652f37330a18886167 /src | |
| parent | 6717a7aca0aaab02bd9ef7b1a934f0853efdc953 (diff) | |
check for float->uint overflow in _mesa_unpack_depth_span()
Diffstat (limited to 'src')
| -rw-r--r-- | src/mesa/main/image.c | 19 | 
1 files changed, 16 insertions, 3 deletions
| diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index a82b540ed6..fbc7147f93 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,6 +1,6 @@  /*   * Mesa 3-D graphics library - * Version:  6.5 + * Version:  6.5.1   *   * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.   * @@ -3953,8 +3953,21 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,     if (dstType == GL_UNSIGNED_INT) {        GLuint *zValues = (GLuint *) dest;        GLuint i; -      for (i = 0; i < n; i++) { -         zValues[i] = (GLuint) (depthValues[i] * depthScale); +      if (depthScale <= (GLfloat) 0xffffff) { +         /* no overflow worries */ +         for (i = 0; i < n; i++) { +            zValues[i] = (GLuint) (depthValues[i] * depthScale); +         } +      } +      else { +         /* need to use double precision to prevent overflow problems */ +         for (i = 0; i < n; i++) { +            GLdouble z = depthValues[i] * depthScale; +            if (z >= (GLdouble) 0xffffffff) +               zValues[i] = 0xffffffff; +            else +               zValues[i] = (GLuint) z; +         }        }     }     else if (dstType == GL_UNSIGNED_SHORT) { | 
