Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: src/core/SkAdvancedTypefaceMetrics.cpp

Issue 1955033002: SkAdvancedTypefaceMetrics: improve robustness (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-05-06 (Friday) 09:17:03 EDT Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkAdvancedTypefaceMetrics.cpp
diff --git a/src/core/SkAdvancedTypefaceMetrics.cpp b/src/core/SkAdvancedTypefaceMetrics.cpp
index ce2c15b3458a1bdb0dc394b1e059fe0f4e955ec7..318f4a06bc23cbbb4801a76ea55b7f156360db75 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;

Powered by Google App Engine
This is Rietveld 408576698