[Mesa-dev] [PATCH] mesa/objectlabel: don't do memcpy if bufSize is 0 (v2)

Dave Airlie airlied at gmail.com
Tue May 3 07:40:47 UTC 2016


From: Dave Airlie <airlied at redhat.com>

This prevents GL43-CTS.khr_debug.labels_non_debug from
memcpying all over the stack and crashing.

v2: actually fix the test.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/mesa/main/objectlabel.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/mesa/main/objectlabel.c b/src/mesa/main/objectlabel.c
index b622d6a..b77cb5c 100644
--- a/src/mesa/main/objectlabel.c
+++ b/src/mesa/main/objectlabel.c
@@ -104,6 +104,11 @@ copy_label(const GLchar *src, GLchar *dst, GLsizei *length, GLsizei bufSize)
     * will be returned in <length>."
     */
 
+   if (bufSize == 0) {
+      if (length)
+         *length = strlen(src);
+      return;
+   }
    if (src)
       labelLen = strlen(src);
 
-- 
2.5.5



More information about the mesa-dev mailing list