1 |
From 6c7f03bb5bb88366ad255983c9d7b7d9a9e1e8df Mon Sep 17 00:00:00 2001 |
2 |
From: Mark Janes <mark.a.janes@intel.com> |
3 |
Date: Thu, 6 Dec 2018 16:35:42 -0800 |
4 |
Subject: [PATCH 12/24] mesa: properly report the length of truncated log |
5 |
messages |
6 |
|
7 |
_mesa_log_msg must provide the length of the string passed into the |
8 |
KHR_debug api. When the string formatted by _mesa_gl_vdebugf exceeds |
9 |
MAX_DEBUG_MESSAGE_LENGTH, the length is incorrectly set to the number |
10 |
of characters that would have been written if enough space had been |
11 |
available. |
12 |
|
13 |
Fixes: 30256805784450b8bb9d4dabfb56226271ca9d24 |
14 |
("mesa: Add support for GL_ARB_debug_output with dynamic ID allocation.") |
15 |
|
16 |
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> |
17 |
(cherry picked from commit eb1a869a5d19bfd8a0d4099afd58f180997e4663) |
18 |
--- |
19 |
src/mesa/main/errors.c | 3 +++ |
20 |
1 file changed, 3 insertions(+) |
21 |
|
22 |
diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c |
23 |
index a9687913627..30560ba047e 100644 |
24 |
--- a/src/mesa/main/errors.c |
25 |
+++ b/src/mesa/main/errors.c |
26 |
@@ -231,6 +231,9 @@ _mesa_gl_vdebug(struct gl_context *ctx, |
27 |
_mesa_debug_get_id(id); |
28 |
|
29 |
len = _mesa_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args); |
30 |
+ if (len >= MAX_DEBUG_MESSAGE_LENGTH) |
31 |
+ /* message was truncated */ |
32 |
+ len = MAX_DEBUG_MESSAGE_LENGTH - 1; |
33 |
|
34 |
_mesa_log_msg(ctx, source, type, *id, severity, len, s); |
35 |
} |
36 |
-- |
37 |
2.21.0 |
38 |
|