[Mesa-dev] [PATCH 2/2] mesa: check for bufSize > 0 in _mesa_GetSynciv()

Brian Paul brianp at vmware.com
Sat Sep 14 09:16:39 PDT 2013


The spec doesn't say GL_INVALID_VALUE should be raised for bufSize <= 0.
In any case, memcpy(len < 0) will lead to a crash, so don't allow it.
---
 src/mesa/main/syncobj.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/syncobj.c b/src/mesa/main/syncobj.c
index 27867a1..ad21f3b 100644
--- a/src/mesa/main/syncobj.c
+++ b/src/mesa/main/syncobj.c
@@ -418,7 +418,7 @@ _mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length,
       return;
    }
 
-   if (size > 0) {
+   if (size > 0 && bufSize > 0) {
       const GLsizei copy_count = MIN2(size, bufSize);
 
       memcpy(values, v, sizeof(GLint) * copy_count);
-- 
1.7.10.4



More information about the mesa-dev mailing list