aboutsummaryrefslogtreecommitdiff
path: root/cpp/src/sfntly/table/core
diff options
context:
space:
mode:
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