Fix memory leak in GetTableData() and add unittests for it
Review URL: https://codereview.appspot.com/5693048
git-svn-id: http://skia.googlecode.com/svn/trunk@3239 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/FontHostTest.cpp b/tests/FontHostTest.cpp
index 2b83658..8ab7ad3 100644
--- a/tests/FontHostTest.cpp
+++ b/tests/FontHostTest.cpp
@@ -31,7 +31,9 @@
SkAutoTMalloc<SkFontTableTag> storage(count);
SkFontTableTag* tags = storage.get();
- SkFontHost::GetTableTags(fontID, tags);
+
+ int count2 = SkFontHost::GetTableTags(fontID, tags);
+ REPORTER_ASSERT(reporter, count2 == count);
for (int i = 0; i < count; ++i) {
size_t size = SkFontHost::GetTableSize(fontID, tags[i]);
@@ -52,6 +54,14 @@
REPORTER_ASSERT(reporter, gKnownTableSizes[j].fSize == size);
}
}
+
+ // do we get the same size from GetTableData and GetTableSize
+ {
+ SkAutoMalloc data(size);
+ size_t size2 = SkFontHost::GetTableData(fontID, tags[i], 0, size,
+ data.get());
+ REPORTER_ASSERT(reporter, size2 == size);
+ }
}
}