[Mesa-dev] [PATCH] st/mesa: don't clobber glGetInternalformat* buffer for GL_NUM_SAMPLE_COUNTS

Nicolai Hähnle nhaehnle at gmail.com
Fri Oct 6 20:13:10 UTC 2017

From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Applications might pass in a buffer that is sized too large and rely
on the extra space of the buffer not being overwritten.

Fixes dEQP-GLES31.functional.state_query.internal_format.partial_query.num_sample_counts

Cc: mesa-stable at lists.freedesktop.org
 src/mesa/state_tracker/st_format.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 5e38fe56890..65be09cbde2 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -2371,23 +2371,24 @@ st_QueryInternalFormat(struct gl_context *ctx, GLenum target,
     * and guaranteed to have at least 16 elements.
    assert(params != NULL);
    switch (pname) {
    case GL_SAMPLES:
       st_QuerySamplesForFormat(ctx, target, internalFormat, params);
+      int samples[16];
       size_t num_samples;
       num_samples = st_QuerySamplesForFormat(ctx, target, internalFormat,
-                                             params);
+                                             samples);
       params[0] = (GLint) num_samples;
       params[0] = GL_NONE;
       /* We need to resolve an internal format that is compatible with
        * the passed internal format, and optimal to the driver. By now,
        * we just validate that the passed internal format is supported by
        * the driver, and if so return the same internal format, otherwise

More information about the mesa-dev mailing list