From 6e3ebcb48392b2b0550017f7f554a2371e546052 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 26 Mar 2019 14:09:18 +0000 Subject: [PATCH] Just skip GL function calls if we don't have function pointers * This is completely invalid but better than crashing. This can happen as a race-condition if the user injects into a running program that's already using GL on one thread, before we've completed installing our hooks. --- renderdoc/driver/gl/gl_hooks.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/renderdoc/driver/gl/gl_hooks.cpp b/renderdoc/driver/gl/gl_hooks.cpp index ba334223f..b09b1f727 100644 --- a/renderdoc/driver/gl/gl_hooks.cpp +++ b/renderdoc/driver/gl/gl_hooks.cpp @@ -116,12 +116,26 @@ void DisableGLHooks() glhook.enabled = false; } +template +ret_type default_ret() +{ + return (ret_type)0; +} + +template <> +void default_ret() +{ +} + // if we were injected and aren't ready to capture, skip out and call the real function #define UNINIT_CALL(function, ...) \ if(!glhook.enabled) \ { \ if(GL.function == NULL) \ + { \ RDCERR("No function pointer for '%s' while uninitialised!", STRINGIZE(function)); \ + return default_ret(); \ + } \ return GL.function(__VA_ARGS__); \ }