aboutsummaryrefslogtreecommitdiff
path: root/loader/debug_report.c
diff options
context:
space:
mode:
authorMark Young <marky@lunarg.com>2016-11-21 16:20:06 -0700
committerMark Young <marky@lunarg.com>2016-11-22 08:37:24 -0700
commit9b54e562500171aa61ab7e3d2700cd2b5a0b2fa7 (patch)
treef9ee99629dc5841aaafde6071db6821613641763 /loader/debug_report.c
parentecdada1af9b43308e95d4317373b4d73b5469776 (diff)
downloadusermoji-9b54e562500171aa61ab7e3d2700cd2b5a0b2fa7.tar.xz
loader: Fix debug report memory leaks
Found a couple of memory leaks in the debug report code in the loader while testing out allocators in cube. Change-Id: I56b401394ca43bd8eb9b4f85baa52dfa597a6f49
Diffstat (limited to 'loader/debug_report.c')
-rw-r--r--loader/debug_report.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/loader/debug_report.c b/loader/debug_report.c
index f71896e7..b404a51a 100644
--- a/loader/debug_report.c
+++ b/loader/debug_report.c
@@ -215,14 +215,18 @@ VkResult util_CopyDebugReportCreateInfos(
((VkDebugReportCallbackEXT *)pAllocator->pfnAllocation(
pAllocator->pUserData, n * sizeof(VkDebugReportCallbackEXT),
sizeof(void *), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
+ if (!pCallbacks) {
+ pAllocator->pfnFree(pAllocator->pUserData, pInfos);
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+ }
} else {
#endif
pCallbacks = *callbacks = ((VkDebugReportCallbackEXT *)malloc(
n * sizeof(VkDebugReportCallbackEXT)));
- }
- if (!pCallbacks) {
- free(pInfos);
- return VK_ERROR_OUT_OF_HOST_MEMORY;
+ if (!pCallbacks) {
+ free(pInfos);
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+ }
}
// 4th, copy each VkDebugReportCallbackCreateInfoEXT for use by
// vkDestroyInstance, and assign a unique handle to each callback (just
@@ -244,8 +248,17 @@ VkResult util_CopyDebugReportCreateInfos(
void util_FreeDebugReportCreateInfos(const VkAllocationCallbacks *pAllocator,
VkDebugReportCallbackCreateInfoEXT *infos,
VkDebugReportCallbackEXT *callbacks) {
- free(infos);
- free(callbacks);
+#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
+ {
+#else
+ if (pAllocator != NULL) {
+ pAllocator->pfnFree(pAllocator->pUserData, infos);
+ pAllocator->pfnFree(pAllocator->pUserData, callbacks);
+ } else {
+#endif
+ free(infos);
+ free(callbacks);
+ }
}
VkResult util_CreateDebugReportCallbacks(
@@ -450,6 +463,16 @@ VKAPI_ATTR void VKAPI_CALL terminator_DestroyDebugReportCallback(
}
storage_idx++;
}
+
+#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
+ {
+#else
+ if (pAllocator != NULL) {
+ pAllocator->pfnFree(pAllocator->pUserData, icd_info);
+ } else {
+#endif
+ free(icd_info);
+ }
}
/*