aboutsummaryrefslogtreecommitdiff
path: root/cpp/src/sfntly/table/core
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2017-04-07 10:50:33 -0700
committerColin Cross <ccross@android.com>2017-04-07 11:01:22 -0700
commitd7c3ad1d95c38b33c49a462f2647dc10f1fff7b7 (patch)
treea77368b5efd882b6d7c224d8fd9f5b6948d48071 /cpp/src/sfntly/table/core
parentd4aea7c865084a140a965d4c413c6c38f9a2743a (diff)
parent64f78562d2003eb7cacaaa86a398cbd41881ba6f (diff)
downloadsfntly-d7c3ad1d95c38b33c49a462f2647dc10f1fff7b7.tar.gz
Merge remote-tracking branch 'aosp/upstream-master' into master
Bug: 32096780 Test: mmma -j external/skia Change-Id: Ia60d7b9984c1007e82bfea10c1a6df32418100d5 (cherry picked from commit bd503d67f403ca1e1d33226626c494d5513701e4)
Diffstat (limited to 'cpp/src/sfntly/table/core')
-rw-r--r--cpp/src/sfntly/table/core/font_header_table.cc5
-rw-r--r--cpp/src/sfntly/table/core/font_header_table.h1
-rw-r--r--cpp/src/sfntly/table/core/name_table.cc10
-rw-r--r--cpp/src/sfntly/table/core/os2_table.cc2
4 files changed, 13 insertions, 5 deletions
diff --git a/cpp/src/sfntly/table/core/font_header_table.cc b/cpp/src/sfntly/table/core/font_header_table.cc
index 60015ca..a848afd 100644
--- a/cpp/src/sfntly/table/core/font_header_table.cc
+++ b/cpp/src/sfntly/table/core/font_header_table.cc
@@ -239,7 +239,10 @@ void FontHeaderTable::Builder::SetFontDirectionHint(int32_t hint) {
}
int32_t FontHeaderTable::Builder::IndexToLocFormat() {
- return down_cast<FontHeaderTable*>(GetTable())->IndexToLocFormat();
+ Table* table = GetTable();
+ if (!table)
+ return IndexToLocFormat::kInvalidOffset;
+ return down_cast<FontHeaderTable*>(table)->IndexToLocFormat();
}
void FontHeaderTable::Builder::SetIndexToLocFormat(int32_t format) {
diff --git a/cpp/src/sfntly/table/core/font_header_table.h b/cpp/src/sfntly/table/core/font_header_table.h
index 841955b..4851775 100644
--- a/cpp/src/sfntly/table/core/font_header_table.h
+++ b/cpp/src/sfntly/table/core/font_header_table.h
@@ -24,6 +24,7 @@ namespace sfntly {
struct IndexToLocFormat {
enum {
+ kInvalidOffset = -1,
kShortOffset = 0,
kLongOffset = 1
};
diff --git a/cpp/src/sfntly/table/core/name_table.cc b/cpp/src/sfntly/table/core/name_table.cc
index 8d2f64f..c9fe468 100644
--- a/cpp/src/sfntly/table/core/name_table.cc
+++ b/cpp/src/sfntly/table/core/name_table.cc
@@ -469,12 +469,14 @@ int32_t NameTable::NameId(int32_t index) {
void NameTable::NameAsBytes(int32_t index, ByteVector* b) {
assert(b);
- int32_t length = NameLength(index);
b->clear();
+
+ int32_t length = NameLength(index);
+ if (length <= 0)
+ return;
+
b->resize(length);
- if (length > 0) {
- data_->ReadBytes(NameOffset(index), &((*b)[0]), 0, length);
- }
+ data_->ReadBytes(NameOffset(index), &((*b)[0]), 0, length);
}
void NameTable::NameAsBytes(int32_t platform_id,
diff --git a/cpp/src/sfntly/table/core/os2_table.cc b/cpp/src/sfntly/table/core/os2_table.cc
index 7ca9d9a..1fef309 100644
--- a/cpp/src/sfntly/table/core/os2_table.cc
+++ b/cpp/src/sfntly/table/core/os2_table.cc
@@ -16,6 +16,8 @@
#include "sfntly/table/core/os2_table.h"
+#include <algorithm>
+
namespace sfntly {
/******************************************************************************
* Constants