diff options
author | Jesse McDonald <nybble41@gmail.com> | 2017-06-27 05:34:11 -0500 |
---|---|---|
committer | SmallJoker <mk939@ymail.com> | 2018-06-03 17:31:59 +0200 |
commit | 46ff2e2cefe55d3511da06c210ea16cbbc1c9ee3 (patch) | |
tree | 05825db0377b0da6d7ce62ba2421df6ec6fd07a3 | |
parent | a08a93bc9c64ee426132424770fc28bf15457db9 (diff) | |
download | minetest-46ff2e2cefe55d3511da06c210ea16cbbc1c9ee3.tar.gz minetest-46ff2e2cefe55d3511da06c210ea16cbbc1c9ee3.tar.bz2 minetest-46ff2e2cefe55d3511da06c210ea16cbbc1c9ee3.zip |
Fix for empty key/value when reading item string with wear but no metadata (#6058)
-rw-r--r-- | src/itemstackmetadata.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/itemstackmetadata.cpp b/src/itemstackmetadata.cpp index c3d602245..65829fd68 100644 --- a/src/itemstackmetadata.cpp +++ b/src/itemstackmetadata.cpp @@ -28,16 +28,18 @@ void ItemStackMetadata::deSerialize(std::istream &is) m_stringvars.clear(); - if (!in.empty() && in[0] == DESERIALIZE_START) { - Strfnd fnd(in); - fnd.to(1); - while (!fnd.at_end()) { - std::string name = fnd.next(DESERIALIZE_KV_DELIM_STR); - std::string var = fnd.next(DESERIALIZE_PAIR_DELIM_STR); - m_stringvars[name] = var; + if (!in.empty()) { + if (in[0] == DESERIALIZE_START) { + Strfnd fnd(in); + fnd.to(1); + while (!fnd.at_end()) { + std::string name = fnd.next(DESERIALIZE_KV_DELIM_STR); + std::string var = fnd.next(DESERIALIZE_PAIR_DELIM_STR); + m_stringvars[name] = var; + } + } else { + // BACKWARDS COMPATIBILITY + m_stringvars[""] = in; } - } else { - // BACKWARDS COMPATIBILITY - m_stringvars[""] = in; } } |