diff --git a/CMakeLists.txt b/CMakeLists.txt index a7bf46d06..4f37fd48b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,7 +231,12 @@ else() add_compile_options(-fno-asynchronous-unwind-tables) endif() - if(METAFORCE_MSAN) + if (METAFORCE_ASAN) + add_compile_options($<$:-stdlib=libc++> -fsanitize=address + -fsanitize-address-use-after-scope) + add_link_options($<$:-stdlib=libc++> -fsanitize=address + -fsanitize-address-use-after-scope) + elseif(METAFORCE_MSAN) add_compile_options($<$:-stdlib=libc++> -fsanitize=memory -fsanitize-memory-track-origins -fsanitize-recover=all) endif() @@ -250,10 +255,6 @@ else() if(APPLE) add_compile_options(-Wno-error=deprecated-declarations $<$:-flto=thin>) - if (METAFORCE_ASAN) - add_compile_options(-fsanitize=address -fsanitize-address-use-after-scope) - add_link_options(-fsanitize=address -fsanitize-address-use-after-scope) - endif () endif() endif() diff --git a/CMakePresets.json b/CMakePresets.json index ebd2a3aad..c4647cca3 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -85,6 +85,32 @@ "linux-clang" ] }, + { + "name": "linux-clang-debug-asan", + "displayName": "Linux (Clang) Debug w/ ASAN", + "inherits": [ + "linux-clang-debug" + ], + "cacheVariables": { + "METAFORCE_ASAN": { + "type": "BOOL", + "value": true + } + } + }, + { + "name": "linux-clang-relwithdebinfo-asan", + "displayName": "Linux (Clang) RelWithDebInfo w/ ASAN", + "inherits": [ + "linux-clang-relwithdebinfo" + ], + "cacheVariables": { + "METAFORCE_ASAN": { + "type": "BOOL", + "value": true + } + } + }, { "name": "windows-msvc", "displayName": "Windows (MSVC)", @@ -295,6 +321,18 @@ "description": "Linux (Clang) release build with debug info", "displayName": "Linux (Clang) RelWithDebInfo" }, + { + "name": "linux-clang-debug-asan", + "configurePreset": "linux-clang-debug-asan", + "description": "Linux (Clang) debug build w/ ASAN", + "displayName": "Linux (Clang) Debug w/ ASAN" + }, + { + "name": "linux-clang-relwithdebinfo-asan", + "configurePreset": "linux-clang-relwithdebinfo-asan", + "description": "Linux (Clang) release build with debug info w/ ASAN", + "displayName": "Linux (Clang) RelWithDebInfo w/ ASAN" + }, { "name": "macos-default-debug", "configurePreset": "macos-default-debug", diff --git a/extern/athena b/extern/athena index f27a63f31..01970c724 160000 --- a/extern/athena +++ b/extern/athena @@ -1 +1 @@ -Subproject commit f27a63f312ba15b986e186b993d9d201d63a118b +Subproject commit 01970c7249cfa30487da40b29e98ad3a5e51ae76 diff --git a/imgui/ImGuiEngine.cpp b/imgui/ImGuiEngine.cpp index 0e6701ef3..e3532ad32 100644 --- a/imgui/ImGuiEngine.cpp +++ b/imgui/ImGuiEngine.cpp @@ -136,9 +136,13 @@ Icon GetIcon() { int iconHeight = 0; auto* data = stbi_load_from_memory(static_cast(METAFORCE_ICON), int(METAFORCE_ICON_SZ), &iconWidth, &iconHeight, nullptr, 4); + size_t size = static_cast(iconWidth) * static_cast(iconHeight) * 4; + auto ptr = std::make_unique(size); + memcpy(ptr.get(), data, size); + stbi_image_free(data); return Icon{ - std::unique_ptr{data}, - static_cast(iconWidth) * static_cast(iconHeight) * 4, + std::move(ptr), + size, static_cast(iconWidth), static_cast(iconHeight), };