summaryrefslogtreecommitdiffhomepage
path: root/loader
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-03-05 23:21:34 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-03-05 23:21:34 +0100
commitcd06aed7c3aaafe665d1d18e6e9032e4bf7b4aef (patch)
tree123743462ea726c8a3d14b49280f1bcc131b64c9 /loader
parentfeacc66350575be00525f78005decf443d9331bd (diff)
loader: don't pass a NULL src pointer to memcpy with zero length (asan)
Diffstat (limited to 'loader')
-rw-r--r--loader/atlas.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/loader/atlas.cpp b/loader/atlas.cpp
index 63025122..c893e633 100644
--- a/loader/atlas.cpp
+++ b/loader/atlas.cpp
@@ -22,9 +22,11 @@ StringView loader_::make_atlas_path(char(&buf)[fm_FILENAME_MAX], StringView dir,
const auto dirsiz = dir.size(), namesiz = name.size(), extsiz = ext.size(),
len = dirsiz + namesiz + extsiz;
fm_soft_assert(len < fm_FILENAME_MAX);
- std::memcpy(&buf[0], dir.data(), dirsiz);
- std::memcpy(&buf[dirsiz], name.data(), namesiz);
- std::memcpy(&buf[dirsiz + namesiz], ext.data(), extsiz);
+ if (dir)
+ std::memcpy(&buf[0], dir.data(), dirsiz);
+ std::memcpy(&buf[dirsiz], name.data(), namesiz);
+ if (ext)
+ std::memcpy(&buf[dirsiz + namesiz], ext.data(), extsiz);
buf[len] = '\0';
return StringView{buf, len, StringViewFlag::NullTerminated};
}