mirror of
https://github.com/KhronosGroup/Vulkan-Utility-Libraries.git
synced 2025-05-25 05:59:24 +00:00
Fix UBSAN error
Calling memcpy with either src or dst as nullptr is undefined even if the count is 0. Discovered by running tests with -fsanitize=undefined safe_struct.extension_add_remove specifcially
This commit is contained in:
parent
ad2ffcba7b
commit
4ee0833a3c
2 changed files with 19 additions and 2 deletions
|
@ -25,6 +25,22 @@ add_subdirectory(scripts)
|
||||||
|
|
||||||
find_package(VulkanHeaders CONFIG)
|
find_package(VulkanHeaders CONFIG)
|
||||||
|
|
||||||
|
option(VUL_ENABLE_ASAN "Use address sanitization")
|
||||||
|
if (VUL_ENABLE_ASAN)
|
||||||
|
add_compile_options(-fsanitize=address)
|
||||||
|
if (NOT MSVC)
|
||||||
|
add_link_options(-fsanitize=address)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(VUL_ENABLE_UBSAN "Use undefined behavior sanitization")
|
||||||
|
if (VUL_ENABLE_UBSAN)
|
||||||
|
if (NOT MSVC)
|
||||||
|
add_compile_options(-fsanitize=undefined)
|
||||||
|
add_link_options(-fsanitize=undefined)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(include)
|
add_subdirectory(include)
|
||||||
|
|
||||||
|
@ -37,7 +53,6 @@ if (PROJECT_IS_TOP_LEVEL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(VUL_ENABLE_INSTALL "Enable install" ${PROJECT_IS_TOP_LEVEL})
|
option(VUL_ENABLE_INSTALL "Enable install" ${PROJECT_IS_TOP_LEVEL})
|
||||||
|
|
||||||
if (VUL_ENABLE_INSTALL)
|
if (VUL_ENABLE_INSTALL)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
|
@ -83,7 +83,9 @@ bool AddExtension(CreateInfo& ci, const char* extension_name) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
char** exts = new char*[ci.enabledExtensionCount + 1];
|
char** exts = new char*[ci.enabledExtensionCount + 1];
|
||||||
|
if (ci.ppEnabledExtensionNames) {
|
||||||
memcpy(exts, ci.ppEnabledExtensionNames, sizeof(char*) * ci.enabledExtensionCount);
|
memcpy(exts, ci.ppEnabledExtensionNames, sizeof(char*) * ci.enabledExtensionCount);
|
||||||
|
}
|
||||||
exts[ci.enabledExtensionCount] = SafeStringCopy(extension_name);
|
exts[ci.enabledExtensionCount] = SafeStringCopy(extension_name);
|
||||||
delete[] ci.ppEnabledExtensionNames;
|
delete[] ci.ppEnabledExtensionNames;
|
||||||
ci.ppEnabledExtensionNames = exts;
|
ci.ppEnabledExtensionNames = exts;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue