mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-08 06:20:19 +01:00
mesa: Don't write to user buffer in glGetTexParameterIuiv on error
With some sets of optimization flags, GCC will generate warnings like
this:
src/mesa/main/texparam.c:2327:27: warning: ‘*((void *)&ip+12)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
params[3] = ip[3];
~~^~~
src/mesa/main/texparam.c:2320:16: note: ‘*((void *)&ip+12)’ was declared here
GLint ip[4];
^~
ip is not initialized in cases where a GL error is generated. In these
cases, we should *not* write to the user's buffer, so this is actually a
bug. I wrote a new piglit test gl-3.0-texparameteri to show this bug.
I suspect that Coverity also detected this, but the scan site is
currently down.
Fixes: c2c507786 "main: Added entry points for glGetTextureParameteriv, Iiv, and Iuiv."
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
(cherry picked from commit def0030e64)
This commit is contained in:
parent
676af78077
commit
582cae39bd
1 changed files with 2 additions and 26 deletions
|
|
@ -2306,30 +2306,6 @@ get_tex_parameterIiv(struct gl_context *ctx,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_tex_parameterIuiv(struct gl_context *ctx,
|
||||
struct gl_texture_object *obj,
|
||||
GLenum pname, GLuint *params, bool dsa)
|
||||
{
|
||||
switch (pname) {
|
||||
case GL_TEXTURE_BORDER_COLOR:
|
||||
COPY_4V(params, obj->Sampler.BorderColor.i);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
GLint ip[4];
|
||||
get_tex_parameteriv(ctx, obj, pname, ip, dsa);
|
||||
params[0] = ip[0];
|
||||
if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT ||
|
||||
pname == GL_TEXTURE_CROP_RECT_OES) {
|
||||
params[1] = ip[1];
|
||||
params[2] = ip[2];
|
||||
params[3] = ip[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
|
||||
{
|
||||
|
|
@ -2382,7 +2358,7 @@ _mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params)
|
|||
if (!texObj)
|
||||
return;
|
||||
|
||||
get_tex_parameterIuiv(ctx, texObj, pname, params, false);
|
||||
get_tex_parameterIiv(ctx, texObj, pname, (GLint *) params, false);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2436,5 +2412,5 @@ _mesa_GetTextureParameterIuiv(GLuint texture, GLenum pname, GLuint *params)
|
|||
if (!texObj)
|
||||
return;
|
||||
|
||||
get_tex_parameterIuiv(ctx, texObj, pname, params, true);
|
||||
get_tex_parameterIiv(ctx, texObj, pname, (GLint *) params, true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue