anv: avoid segmentation fault due to vk_error()
authorSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Fri, 19 Jan 2018 07:45:10 +0000 (08:45 +0100)
committerSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Fri, 19 Jan 2018 08:39:05 +0000 (09:39 +0100)
vk_error() is a macro that calls __vk_errorf() with instance == NULL.

Then, __vk_errorf() passes a pointer to instance->debug_report_callbacks
to vk_debug_error(), which segfaults as this pointer is invalid but not
NULL.

Fixes: e5b1bd6ab8 "vulkan: move anv VK_EXT_debug_report implementation to common code."
Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/intel/vulkan/anv_util.c

index 6b31224d7f10433b389618c24168a2693840db2e..3c1803aa05668fd6e8f36cef8f98dc9ccde893e4 100644 (file)
@@ -99,14 +99,16 @@ __vk_errorf(struct anv_instance *instance, const void *object,
       snprintf(report, sizeof(report), "%s:%d: %s", file, line, error_str);
    }
 
-   vk_debug_report(&instance->debug_report_callbacks,
-                   VK_DEBUG_REPORT_ERROR_BIT_EXT,
-                   type,
-                   (uint64_t) (uintptr_t) object,
-                   line,
-                   0,
-                   "anv",
-                   report);
+   if (instance) {
+      vk_debug_report(&instance->debug_report_callbacks,
+                      VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                      type,
+                      (uint64_t) (uintptr_t) object,
+                      line,
+                      0,
+                      "anv",
+                      report);
+   }
 
    intel_loge("%s", report);