mesa/objectlabel: don't do memcpy if bufSize is 0 (v2)
authorDave Airlie <airlied@redhat.com>
Tue, 3 May 2016 07:32:28 +0000 (17:32 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 3 May 2016 10:12:59 +0000 (20:12 +1000)
This prevents GL43-CTS.khr_debug.labels_non_debug from
memcpying all over the stack and crashing.

v2: actually fix the test.

Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/mesa/main/objectlabel.c

index b622d6a2979227350da5f8f5a92e735d4f26844e..b77cb5c4e36767b24e8b75ae011c0d46148bb75f 100644 (file)
@@ -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);