aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkAdvancedTypefaceMetrics.cpp16
-rw-r--r--src/core/SkAdvancedTypefaceMetrics.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/src/core/SkAdvancedTypefaceMetrics.cpp b/src/core/SkAdvancedTypefaceMetrics.cpp
index ce2c15b345..318f4a06bc 100644
--- a/src/core/SkAdvancedTypefaceMetrics.cpp
+++ b/src/core/SkAdvancedTypefaceMetrics.cpp
@@ -27,6 +27,22 @@ typedef struct FT_FaceRec_* FT_Face;
#include <CoreFoundation/CoreFoundation.h>
#endif
+template <typename Data>
+static void unwind(SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* ptr) {
+ while (ptr) {
+ SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* next = ptr->fNext.release();
+ delete ptr;
+ ptr = next;
+ }
+}
+
+SkAdvancedTypefaceMetrics::~SkAdvancedTypefaceMetrics() {
+ // If the stacks are too deep we could get stack overflow,
+ // so we manually destruct the linked lists.
+ unwind(fGlyphWidths.release());
+ unwind(fVerticalMetrics.release());
+}
+
namespace skia_advanced_typeface_metrics_utils {
const int16_t kInvalidAdvance = SK_MinS16;
diff --git a/src/core/SkAdvancedTypefaceMetrics.h b/src/core/SkAdvancedTypefaceMetrics.h
index 329b7d13c1..eae7318215 100644
--- a/src/core/SkAdvancedTypefaceMetrics.h
+++ b/src/core/SkAdvancedTypefaceMetrics.h
@@ -66,6 +66,8 @@ public:
, fCapHeight(0)
, fBBox(SkIRect::MakeEmpty()) {}
+ ~SkAdvancedTypefaceMetrics();
+
SkString fFontName;
enum FontType {