Asset Indexer: use fixed-length string for ID code

Use fixed-length string to convert `char[2]` to `std::string`. Otherwise
`strlen()` is called, which is problematic as the `char[2]` is not
zero-terminated.
This commit is contained in:
Sybren A. Stüvel
2021-12-06 17:42:07 +01:00
parent c2292b2cd6
commit 86992a96b8

View File

@@ -237,7 +237,7 @@ struct AssetEntryWriter {
char idcode_prefix[2];
/* Similar to `BKE_libblock_alloc`. */
*((short *)idcode_prefix) = idcode;
std::string name_with_idcode = std::string(idcode_prefix) + name;
std::string name_with_idcode = std::string(idcode_prefix, sizeof(idcode_prefix)) + name;
attributes.append_as(std::pair(ATTRIBUTE_ENTRIES_NAME, new StringValue(name_with_idcode)));
}