From 5989a2937f6a77e8f32ccc30cc7f9b3bd7bed9eb Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 3 May 2016 17:32:28 +1000 Subject: [PATCH] mesa/objectlabel: don't do memcpy if bufSize is 0 (v2) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Dave Airlie --- 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 ." */ + if (bufSize == 0) { + if (length) + *length = strlen(src); + return; + } if (src) labelLen = strlen(src); -- 2.7.4