aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <leizleiz@users.noreply.github.com>2016-06-09 23:30:26 -0700
committerLei Zhang <leizleiz@users.noreply.github.com>2016-06-09 23:30:26 -0700
commitc56b85408bab232efd7e650f0994272a174e3b92 (patch)
tree98ef02e6799d14532e274a204fdf563fe781371d
parent9a04b4bc9c9f090cd2033a0bc3e3a6744e06e1d6 (diff)
downloadsfntly-c56b85408bab232efd7e650f0994272a174e3b92.tar.gz
Add a bounds check to ByteArray::Get().
-rw-r--r--cpp/src/sfntly/data/byte_array.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/cpp/src/sfntly/data/byte_array.cc b/cpp/src/sfntly/data/byte_array.cc
index 915a40c..57f9eed 100644
--- a/cpp/src/sfntly/data/byte_array.cc
+++ b/cpp/src/sfntly/data/byte_array.cc
@@ -35,6 +35,8 @@ int32_t ByteArray::SetFilledLength(int32_t filled_length) {
}
int32_t ByteArray::Get(int32_t index) {
+ if (index < 0 || index >= Length())
+ return -1;
return InternalGet(index) & 0xff;
}