Index: media/webm/webm_parser.cc |
diff --git a/media/webm/webm_parser.cc b/media/webm/webm_parser.cc |
index 9952efa58c701d80814a0bb0ab8f57e84d9cff3f..fb9f8997d350cf6aaafd698fa0de9ed30d37faf7 100644 |
--- a/media/webm/webm_parser.cc |
+++ b/media/webm/webm_parser.cc |
@@ -599,7 +599,9 @@ static int ParseBinary(const uint8* buf, int size, int id, |
static int ParseString(const uint8* buf, int size, int id, |
WebMParserClient* client) { |
- std::string str(reinterpret_cast<const char*>(buf), size); |
+ const uint8* end = static_cast<const uint8*>(memchr(buf, '\0', size)); |
+ int length = (end != NULL) ? static_cast<int>(end - buf) : size; |
+ std::string str(reinterpret_cast<const char*>(buf), length); |
return client->OnString(id, str) ? size : -1; |
} |