summaryrefslogtreecommitdiffhomepage
path: root/main
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-21 14:20:30 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-21 14:20:30 +0200
commit41c9dcd43bc3b2d2508dff46e58cb2b91db2ef65 (patch)
tree255954b9d681bf29dfa692ff82833ef5895e5a16 /main
parent7a38c6c434e03256d9e9fbff87516b3ad1e3958a (diff)
loader: memcpy shenanigans
Diffstat (limited to 'main')
-rw-r--r--main/loader-impl.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/main/loader-impl.cpp b/main/loader-impl.cpp
index 9816fd40..2c37c487 100644
--- a/main/loader-impl.cpp
+++ b/main/loader-impl.cpp
@@ -68,9 +68,10 @@ Trade::ImageData2D loader_impl::tile_texture(Containers::StringView filename_)
static_assert(IMAGE_PATH[sizeof(IMAGE_PATH)-2] == '/');
fm_assert(filename_.size() < 4096);
- char* const filename = (char*)alloca(filename_.size() + sizeof(IMAGE_PATH));
- std::memcpy(filename, IMAGE_PATH, sizeof(IMAGE_PATH)-1);
- std::strcpy(filename + sizeof(IMAGE_PATH)-1, filename_.cbegin());
+ char* const filename = (char*)alloca(filename_.size() + std::size(IMAGE_PATH));
+ std::memcpy(filename, IMAGE_PATH, std::size(IMAGE_PATH)-1);
+ std::memcpy(filename + std::size(IMAGE_PATH)-1, filename_.cbegin(), filename_.size());
+ filename[std::size(IMAGE_PATH)-1 + filename_.size()] = '\0';
if (!tga_importer || !tga_importer->openFile(filename)) {
const auto path = Utility::Path::currentDirectory();
fm_log("note: current working directory: '%s'", path->data());