aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/FontHostStreamTest.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-07 14:32:58 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-07 14:32:58 +0000
commit66f5aaad90b5027daad8acbd5e8d83160097ed95 (patch)
tree7264f33b84d10e982753820aacd5b3f904c91798 /tests/FontHostStreamTest.cpp
parent279627efc53e0a1004b296b1254e4c48082a725e (diff)
Check whether font creation is failed to avoid segment fault.
In some rare cases, SkFontHost::CreateTypeface in src/ports/SkFontHost_fontconfig.cpp will return NULL, this will lead to segment fault because the previous code would access to 0x0 by (SkTypeface *)NULL->unref(). BUG= R=reed@google.com, bungeman@google.com Author: yunchao.he@intel.com Review URL: https://chromiumcodereview.appspot.com/14907005 git-svn-id: http://skia.googlecode.com/svn/trunk@9034 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/FontHostStreamTest.cpp')
-rw-r--r--tests/FontHostStreamTest.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/FontHostStreamTest.cpp b/tests/FontHostStreamTest.cpp
index 4fd88cc4da..30e469b410 100644
--- a/tests/FontHostStreamTest.cpp
+++ b/tests/FontHostStreamTest.cpp
@@ -72,7 +72,9 @@ static void test_fontHostStream(skiatest::Reporter* reporter) {
paint.setColor(SK_ColorGRAY);
paint.setTextSize(SkIntToScalar(30));
- paint.setTypeface(SkTypeface::CreateFromName("Georgia", SkTypeface::kNormal))->unref();
+ SkTypeface* fTypeface = SkTypeface::CreateFromName("Georgia",
+ SkTypeface::kNormal);
+ SkSafeUnref(paint.setTypeface(fTypeface));
SkIRect origRect = SkIRect::MakeWH(64, 64);
SkBitmap origBitmap;