mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
chore: detect non-string textures and fix null terminator on custom shaders
This commit is contained in:
parent
d6bcd62d1a
commit
fd0f142517
@ -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) {
|
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]);
|
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);
|
memcpy (copy.get(), contents.c_str (), length);
|
||||||
|
|
||||||
// finally add to the container
|
// finally add to the container
|
||||||
|
@ -63,7 +63,12 @@ std::map <int, std::string> MaterialParser::parseTextures (const JSON& it) {
|
|||||||
|
|
||||||
for (const auto& cur : it) {
|
for (const auto& cur : it) {
|
||||||
if (!cur.is_null ()) {
|
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++;
|
index++;
|
||||||
|
Loading…
Reference in New Issue
Block a user