From 9759c3d542a8329627c35c5670e232108f91eef0 Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 11 Sep 2015 19:01:03 -0700 Subject: [PATCH] third_party/libwebm: pull from upstream. Upstream hash: 476366249e1fda7710a389cd41c57db42305e0d4 Changes from upstream since last update: 4763662 mkvparser: fix type warnings 267f71c mkvparser: SafeArrayAlloc fix type warning f1a99d5 mkvparser: s/LONG_LONG_MAX/LLONG_MAX/ for compatibility bff1aa5 mkvparser: add msvc compatibility for isnan/isinf Change-Id: Ie0375e564fc74b3b296744d0039830d2f77b83b6 --- third_party/libwebm/README.libvpx | 2 +- third_party/libwebm/mkvparser.cpp | 41 +++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/third_party/libwebm/README.libvpx b/third_party/libwebm/README.libvpx index f07a52b0c..2989d3d89 100644 --- a/third_party/libwebm/README.libvpx +++ b/third_party/libwebm/README.libvpx @@ -1,5 +1,5 @@ URL: https://chromium.googlesource.com/webm/libwebm -Version: a58c32339e06e5d672a58cdd5844cea0a661e735 +Version: 476366249e1fda7710a389cd41c57db42305e0d4 License: BSD License File: LICENSE.txt diff --git a/third_party/libwebm/mkvparser.cpp b/third_party/libwebm/mkvparser.cpp index 4306a5117..f2855d506 100644 --- a/third_party/libwebm/mkvparser.cpp +++ b/third_party/libwebm/mkvparser.cpp @@ -8,6 +8,11 @@ #include "mkvparser.hpp" +#if defined(_MSC_VER) && _MSC_VER < 1800 +#include // _isnan() / _finite() +#define MSC_COMPAT +#endif + #include #include #include @@ -23,6 +28,14 @@ namespace mkvparser { +#ifdef MSC_COMPAT +inline bool isnan(double val) { return !!_isnan(val); } +inline bool isinf(double val) { return !_finite(val); } +#else +inline bool isnan(double val) { return std::isnan(val); } +inline bool isinf(double val) { return std::isinf(val); } +#endif // MSC_COMPAT + IMkvReader::~IMkvReader() {} template Type* SafeArrayAlloc(unsigned long long num_elements, @@ -34,8 +47,10 @@ template Type* SafeArrayAlloc(unsigned long long num_elements, const unsigned long long num_bytes = num_elements * element_size; if (element_size > (kMaxAllocSize / num_elements)) return NULL; + if (num_bytes != static_cast(num_bytes)) + return NULL; - return new (std::nothrow) Type[num_bytes]; + return new (std::nothrow) Type[static_cast(num_bytes)]; } void GetVersion(int& major, int& minor, int& build, int& revision) { @@ -267,7 +282,7 @@ long UnserializeFloat(IMkvReader* pReader, long long pos, long long size_, result = d; } - if (std::isinf(result) || std::isnan(result)) + if (mkvparser::isinf(result) || mkvparser::isnan(result)) return E_FILE_FORMAT_INVALID; return 0; @@ -322,7 +337,7 @@ long UnserializeString(IMkvReader* pReader, long long pos, long long size, unsigned char* const buf = reinterpret_cast(str); - const long status = pReader->Read(pos, size, buf); + const long status = pReader->Read(pos, static_cast(size), buf); if (status) { delete[] str; @@ -361,10 +376,10 @@ long ParseElementHeader(IMkvReader* pReader, long long& pos, return E_FILE_FORMAT_INVALID; } - // Avoid rolling over pos when very close to LONG_LONG_MAX. + // Avoid rolling over pos when very close to LLONG_MAX. const unsigned long long rollover_check = static_cast(pos) + len; - if (rollover_check > LONG_LONG_MAX) + if (rollover_check > LLONG_MAX) return E_FILE_FORMAT_INVALID; pos += len; // consume length of size @@ -443,13 +458,13 @@ bool Match(IMkvReader* pReader, long long& pos, unsigned long expected_id, unsigned long long rollover_check = static_cast(pos) + len; - if (rollover_check > LONG_LONG_MAX) + if (rollover_check > LLONG_MAX) return false; pos += len; // consume length of size of payload rollover_check = static_cast(pos) + size; - if (rollover_check > LONG_LONG_MAX) + if (rollover_check > LLONG_MAX) return false; if ((pos + size) > available) @@ -508,7 +523,7 @@ long long EBMLHeader::Parse(IMkvReader* pReader, long long& pos) { long long end = (available >= 1024) ? 1024 : available; // Scan until we find what looks like the first byte of the EBML header. - const int kMaxScanBytes = (available >= 1024) ? 1024 : available; + const long long kMaxScanBytes = (available >= 1024) ? 1024 : available; const unsigned char kEbmlByte0 = 0x1A; unsigned char scan_byte = 0; @@ -832,9 +847,9 @@ long long Segment::ParseHeaders() { long long pos = m_pos; const long long element_start = pos; - // Avoid rolling over pos when very close to LONG_LONG_MAX. + // Avoid rolling over pos when very close to LLONG_MAX. unsigned long long rollover_check = pos + 1ULL; - if (rollover_check > LONG_LONG_MAX) + if (rollover_check > LLONG_MAX) return E_FILE_FORMAT_INVALID; if ((pos + 1) > available) @@ -898,9 +913,9 @@ long long Segment::ParseHeaders() { pos += len; // consume length of size of element - // Avoid rolling over pos when very close to LONG_LONG_MAX. + // Avoid rolling over pos when very close to LLONG_MAX. rollover_check = static_cast(pos) + size; - if (rollover_check > LONG_LONG_MAX) + if (rollover_check > LLONG_MAX) return E_FILE_FORMAT_INVALID; const long long element_size = size + pos - element_start; @@ -4020,7 +4035,7 @@ long SegmentInfo::Parse() { } const double rollover_check = m_duration * m_timecodeScale; - if (rollover_check > LONG_LONG_MAX) + if (rollover_check > LLONG_MAX) return E_FILE_FORMAT_INVALID; if (pos != stop)