From 740cae64a146f46a21e5ddb624a57c30d0e86053 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Tue, 30 Jul 2024 15:01:37 +0200 Subject: [PATCH] mesa: check for enabled extensions for *UID enums Applications might use them without checking if the extension is supported and would run into a NULL pointer deref calling the callbacks. Cc: mesa-stable Part-of: --- src/mesa/main/get.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 67d9b855c0f..622cb550261 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -2908,20 +2908,28 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v) /* GL_EXT_external_objects */ case GL_NUM_DEVICE_UUIDS_EXT: + if (!ctx->Extensions.EXT_memory_object && !ctx->Extensions.EXT_semaphore) + goto invalid_enum; v->value_int = 1; return TYPE_INT; case GL_DRIVER_UUID_EXT: + if (!ctx->Extensions.EXT_memory_object && !ctx->Extensions.EXT_semaphore) + goto invalid_enum; if (index >= 1) goto invalid_value; _mesa_get_driver_uuid(ctx, v->value_int_4); return TYPE_INT_4; case GL_DEVICE_UUID_EXT: + if (!ctx->Extensions.EXT_memory_object && !ctx->Extensions.EXT_semaphore) + goto invalid_enum; if (index >= 1) goto invalid_value; _mesa_get_device_uuid(ctx, v->value_int_4); return TYPE_INT_4; /* GL_EXT_memory_object_win32 */ case GL_DEVICE_LUID_EXT: + if (!ctx->Extensions.EXT_memory_object_win32 && !ctx->Extensions.EXT_semaphore_win32) + goto invalid_enum; if (index >= 1) goto invalid_value; _mesa_get_device_luid(ctx, v->value_int_2);