[Mesa-dev] [PATCH 10/13] mesa/main: Check context pointer in _mesa_error before using it
Juha-Pekka Heikkila
juhapekka.heikkila at gmail.com
Fri Nov 28 03:25:10 PST 2014
I guess this should not really be able to segfault but still it
seems to be able to during context creation.
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
src/mesa/main/errors.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index 7d622bb..705dea9 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -1438,18 +1438,23 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... )
do_output = should_output(ctx, error, fmtString);
- mtx_lock(&ctx->DebugMutex);
- if (ctx->Debug) {
- do_log = debug_is_message_enabled(ctx->Debug,
- MESA_DEBUG_SOURCE_API,
- MESA_DEBUG_TYPE_ERROR,
- error_msg_id,
- MESA_DEBUG_SEVERITY_HIGH);
+ if (ctx) {
+ mtx_lock(&ctx->DebugMutex);
+ if (ctx->Debug) {
+ do_log = debug_is_message_enabled(ctx->Debug,
+ MESA_DEBUG_SOURCE_API,
+ MESA_DEBUG_TYPE_ERROR,
+ error_msg_id,
+ MESA_DEBUG_SEVERITY_HIGH);
+ }
+ else {
+ do_log = GL_FALSE;
+ }
+ mtx_unlock(&ctx->DebugMutex);
}
else {
do_log = GL_FALSE;
}
- mtx_unlock(&ctx->DebugMutex);
if (do_output || do_log) {
char s[MAX_DEBUG_MESSAGE_LENGTH], s2[MAX_DEBUG_MESSAGE_LENGTH];
@@ -1482,14 +1487,15 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... )
}
/* Log the error via ARB_debug_output if needed.*/
- if (do_log) {
+ if (ctx && do_log) {
log_msg(ctx, MESA_DEBUG_SOURCE_API, MESA_DEBUG_TYPE_ERROR,
error_msg_id, MESA_DEBUG_SEVERITY_HIGH, len, s2);
}
}
/* Set the GL context error state for glGetError. */
- _mesa_record_error(ctx, error);
+ if (ctx)
+ _mesa_record_error(ctx, error);
}
void
--
1.8.5.1
More information about the mesa-dev
mailing list