mesa/objectlabel: handle NULL src string
authorMark Janes <mark.a.janes@intel.com>
Tue, 3 May 2016 20:50:49 +0000 (13:50 -0700)
committerMark Janes <mark.a.janes@intel.com>
Tue, 3 May 2016 21:07:31 +0000 (14:07 -0700)
This prevents a crash when a NULL src is passed with a non-NULL length.

fixes: dEQP-GLES31.functional.debug.object_labels.query_length_only
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95252

Signed-off-by: Mark Janes <mark.a.janes@intel.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/mesa/main/objectlabel.c

index b77cb5c4e36767b24e8b75ae011c0d46148bb75f..5070b0087928850b645f985122061d04a6289b70 100644 (file)
@@ -104,13 +104,14 @@ copy_label(const GLchar *src, GLchar *dst, GLsizei *length, GLsizei bufSize)
     * will be returned in <length>."
     */
 
+   if (src)
+      labelLen = strlen(src);
+
    if (bufSize == 0) {
       if (length)
-         *length = strlen(src);
+         *length = labelLen;
       return;
    }
-   if (src)
-      labelLen = strlen(src);
 
    if (dst) {
       if (src) {