Ver Fonte

another defensive check

Lee Thomason há 1 ano atrás
pai
commit
1fadaae0c9
1 ficheiros alterados com 5 adições e 0 exclusões
  1. 5 0
      tinyxml2.cpp

+ 5 - 0
tinyxml2.cpp

@@ -545,6 +545,11 @@ const char* XMLUtil::GetCharacterRef(const char* p, char* value, int* length)
         }
         // convert the UCS to UTF-8
         ConvertUTF32ToUTF8(ucs, value, length);
+		if (length == 0) {
+            // If length is 0, there was an error. (Security? Bad input?)
+            // Fail safely.
+			return 0;
+		}
         return p + delta + 1;
     }
     return p + 1;