mesa: Don't write to user buffer in glGetTexParameterIuiv on error
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 8 Mar 2018 05:05:34 +0000 (21:05 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 12 Mar 2018 17:13:30 +0000 (10:13 -0700)
commitdef0030e64dd3a4eb3487dd40bf64b9a71a70af3
tree28e35cba63adc1b7e363369ac97efe763b9596b7
parentf94597f554d284e8bedf0d00e3ad9e805306548f
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>
src/mesa/main/texparam.c