chore: detect non-string textures and fix null terminator on custom shaders

This commit is contained in:
Almamu 2025-08-31 15:05:52 +02:00
parent d6bcd62d1a
commit fd0f142517
2 changed files with 8 additions and 3 deletions

View File

@ -10,10 +10,10 @@ void CVirtualContainer::add (const std::filesystem::path& filename, const std::s
}
void CVirtualContainer::add (const std::filesystem::path& filename, const std::string& contents) {
size_t length = contents.length () + 1;
// do not copy the null terminator
size_t length = contents.length ();
std::shared_ptr<uint8_t[]> copy = std::shared_ptr<uint8_t[]> (new uint8_t [length]);
// copy the text AND the \0
memcpy (copy.get(), contents.c_str (), length);
// finally add to the container

View File

@ -63,7 +63,12 @@ std::map <int, std::string> MaterialParser::parseTextures (const JSON& it) {
for (const auto& cur : it) {
if (!cur.is_null ()) {
result.emplace (index, cur);
if (!cur.is_string ()) {
sLog.error ("Detected a non-string texture, most likely a special value: ", cur.dump ());
result.emplace (index, "");
} else {
result.emplace (index, cur);
}
}
index++;