Fix four memory leaks uncovered by valgrinding gm tests.
All are triggered by PDF code.
Two are missing unref's on SkData.
One is a missing unref on a SkAdvancedTypefaceMetrics.
The last is missing destruction of SkClipStack internal state.
BUG=526
Review URL: https://codereview.appspot.com/5824049
git-svn-id: http://skia.googlecode.com/svn/trunk@3386 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp
index 3aea4b8..e0e18cd 100644
--- a/src/pdf/SkPDFFont.cpp
+++ b/src/pdf/SkPDFFont.cpp
@@ -525,7 +525,7 @@
append_cmap_footer(&cmap);
SkRefPtr<SkMemoryStream> cmapStream = new SkMemoryStream();
cmapStream->unref(); // SkRefPtr and new took a reference.
- cmapStream->setData(cmap.copyToData());
+ cmapStream->setData(cmap.copyToData())->unref();
return new SkPDFStream(cmapStream.get());
}
@@ -763,9 +763,8 @@
#endif
fontMetrics =
SkFontHost::GetAdvancedTypefaceMetrics(fontID, info, NULL, 0);
-#if defined (SK_SFNTLY_SUBSETTER)
- SkASSERT(fontMetrics);
SkSafeUnref(fontMetrics.get()); // SkRefPtr and Get both took a ref.
+#if defined (SK_SFNTLY_SUBSETTER)
if (fontMetrics &&
fontMetrics->fType != SkAdvancedTypefaceMetrics::kTrueType_Font) {
// Font does not support subsetting, get new info with advance.