diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-11 01:15:28 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-11 01:15:28 +0100 |
commit | 9e3c0ac3f71cf2148e4788793efea5968f1a46b2 (patch) | |
tree | 68a3a78e39feef9b90bb1c7e6366a6ff4ce84dd0 | |
parent | 760223387603952bd82171ce188649c817452363 (diff) |
loader: add missing null terminated flag
-rw-r--r-- | loader/atlas.cpp | 5 | ||||
-rw-r--r-- | loader/texture.cpp | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/loader/atlas.cpp b/loader/atlas.cpp index 68a94f0b..7d8539da 100644 --- a/loader/atlas.cpp +++ b/loader/atlas.cpp @@ -22,8 +22,9 @@ StringView loader_::make_atlas_path(char(&buf)[FILENAME_MAX], StringView dir, St fm_soft_assert(dirsiz + namesiz + 1 < FILENAME_MAX); std::memcpy(buf, dir.data(), dirsiz); std::memcpy(&buf[dirsiz], name.data(), namesiz); - buf[dirsiz + namesiz] = '\0'; - return StringView{buf}; + auto len = dirsiz + namesiz; + buf[len] = '\0'; + return StringView{buf, len, StringViewFlag::NullTerminated}; } bool loader_::check_atlas_name(StringView str) noexcept diff --git a/loader/texture.cpp b/loader/texture.cpp index a12986b4..60372d00 100644 --- a/loader/texture.cpp +++ b/loader/texture.cpp @@ -33,7 +33,7 @@ Trade::ImageData2D loader_impl::texture(StringView prefix, StringView filename_, fm_soft_assert(len + extension.size() < std::size(buf)); std::memcpy(buf + len, extension.data(), extension.size()); buf[len + extension.size()] = '\0'; - auto path = StringView{buf, len + extension.size()}; + auto path = StringView{buf, len + extension.size(), StringViewFlag::NullTerminated}; fm_debug_assert(path.size() < std::size(buf)); auto& importer = extension == ".tga"_s ? tga_importer : image_importer; if (Path::exists(path) && importer->openFile(path)) |