summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2014-07-24 15:50:56 +0100
committerCarl Worth <cworth@cworth.org>2014-07-30 22:09:46 -0700
commitc84b367b18821e7790015cdb426abab1d9b544d0 (patch)
tree2ce66f862d2b5811f47f32be9a00d1125c8c2614 /src
parent71102219ea97aaee0c6d8076d26857581340535d (diff)
st/wgl: Clamp wglChoosePixelFormatARB's output nNumFormats to nMaxFormats.
While running https://github.com/nvMcJohn/apitest with apitrace I noticed that Mesa was producing bogus results: wglChoosePixelFormatARB(hdc, piAttribIList = {...}, pfAttribFList = &0, nMaxFormats = 1, piFormats = {19, 65576, 37, 198656, 131075, 0, 402653184, 0, 0, 0, 0, -573575710}, nNumFormats = &12) = TRUE However https://www.opengl.org/registry/specs/ARB/wgl_pixel_format.txt states <nNumFormats> returns the number of matching formats. The returned value is guaranteed to be no larger than <nMaxFormats>. Cc: "10.2" <mesa-stable@lists.freedesktop.org> Reviewed-by: Brian Paul <brianp@vmware.com> (cherry picked from commit 66a1b3a1da5cbb75d727c9b4751a06bdd403f0f9)
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/wgl/stw_ext_pixelformat.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c b/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c
index d303b0153c..91682d115a 100644
--- a/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c
+++ b/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c
@@ -448,9 +448,11 @@ wglChoosePixelFormatARB(
*/
for (i = 0; i < count; i++) {
if (scores[i].points > 0) {
- if (*nNumFormats < nMaxFormats)
- piFormats[*nNumFormats] = scores[i].index + 1;
+ piFormats[*nNumFormats] = scores[i].index + 1;
(*nNumFormats)++;
+ if (*nNumFormats >= nMaxFormats) {
+ break;
+ }
}
}