Fix for empty key/value when reading item string with wear but no metadata (#6058)
authorJesse McDonald <nybble41@gmail.com>
Tue, 27 Jun 2017 10:34:11 +0000 (05:34 -0500)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:31:59 +0000 (17:31 +0200)
src/itemstackmetadata.cpp

index c3d6022457d2f27065c944de414489ad38a138e2..65829fd68b251c8a2368c60f3c57251c0493a8e9 100644 (file)
@@ -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;
        }
 }