From: Dave Airlie Date: Tue, 3 May 2016 07:32:28 +0000 (+1000) Subject: mesa/objectlabel: don't do memcpy if bufSize is 0 (v2) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5989a2937f6a77e8f32ccc30cc7f9b3bd7bed9eb;p=mesa.git mesa/objectlabel: don't do memcpy if bufSize is 0 (v2) 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 --- diff --git a/src/mesa/main/objectlabel.c b/src/mesa/main/objectlabel.c index b622d6a2979..b77cb5c4e36 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);