Index: webrtc/modules/rtp_rtcp/source/byte_io.h |
diff --git a/webrtc/modules/rtp_rtcp/source/byte_io.h b/webrtc/modules/rtp_rtcp/source/byte_io.h |
index 2617806dd941205c813a0b0c535f949429a6c97e..c0d519ba4a658749fb5510aca63113c137b92bb7 100644 |
--- a/webrtc/modules/rtp_rtcp/source/byte_io.h |
+++ b/webrtc/modules/rtp_rtcp/source/byte_io.h |
@@ -50,6 +50,7 @@ template<typename T, unsigned int B = sizeof(T), |
class ByteReader { |
public: |
static T ReadBigEndian(const uint8_t* data) { |
+ static_assert(B <= sizeof(T), "Target size too large"); |
if (is_signed && B < sizeof(T)) { |
return SignExtend(InternalReadBigEndian(data)); |
} |
@@ -57,6 +58,7 @@ class ByteReader { |
} |
static T ReadLittleEndian(const uint8_t* data) { |
+ static_assert(B <= sizeof(T), "Target size too large"); |
if (is_signed && B < sizeof(T)) { |
return SignExtend(InternalReadLittleEndian(data)); |
} |
@@ -106,12 +108,14 @@ template<typename T, unsigned int B = sizeof(T)> |
class ByteWriter { |
public: |
static void WriteBigEndian(uint8_t* data, T val) { |
+ static_assert(B <= sizeof(T), "Target size too large"); |
for (unsigned int i = 0; i < B; ++i) { |
data[i] = val >> ((B - 1 - i) * 8); |
} |
} |
static void WriteLittleEndian(uint8_t* data, T val) { |
+ static_assert(B <= sizeof(T), "Target size too large"); |
for (unsigned int i = 0; i < B; ++i) { |
data[i] = val >> (i * 8); |
} |