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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzFace.cpp

Issue 2127553003: Speculative nullptr dereference fix for HarfBuzz face creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 Google Inc. All rights reserved. 2 * Copyright (c) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 { 325 {
326 #if OS(MACOSX) 326 #if OS(MACOSX)
327 hb_face_t* face = hb_coretext_face_create(m_platformData->cgFont()); 327 hb_face_t* face = hb_coretext_face_create(m_platformData->cgFont());
328 #else 328 #else
329 hb_face_t* face = nullptr; 329 hb_face_t* face = nullptr;
330 330
331 DEFINE_STATIC_LOCAL(BooleanHistogram, 331 DEFINE_STATIC_LOCAL(BooleanHistogram,
332 zeroCopySuccessHistogram, 332 zeroCopySuccessHistogram,
333 ("Blink.Fonts.HarfBuzzFaceZeroCopyAccess")); 333 ("Blink.Fonts.HarfBuzzFaceZeroCopyAccess"));
334 SkTypeface* typeface = m_platformData->typeface(); 334 SkTypeface* typeface = m_platformData->typeface();
335 CHECK(typeface);
335 int ttcIndex = 0; 336 int ttcIndex = 0;
336 SkStreamAsset* typefaceStream = typeface->openStream(&ttcIndex); 337 SkStreamAsset* typefaceStream = typeface->openStream(&ttcIndex);
337 if (typefaceStream->getMemoryBase()) { 338 if (typefaceStream && typefaceStream->getMemoryBase()) {
338 std::unique_ptr<hb_blob_t, void(*)(hb_blob_t*)> faceBlob(hb_blob_create( 339 std::unique_ptr<hb_blob_t, void(*)(hb_blob_t*)> faceBlob(hb_blob_create(
339 reinterpret_cast<const char*>(typefaceStream->getMemoryBase()), 340 reinterpret_cast<const char*>(typefaceStream->getMemoryBase()),
340 typefaceStream->getLength(), 341 typefaceStream->getLength(),
341 HB_MEMORY_MODE_READONLY, 342 HB_MEMORY_MODE_READONLY,
342 typefaceStream, 343 typefaceStream,
343 deleteTypefaceStream), 344 deleteTypefaceStream),
344 hb_blob_destroy); 345 hb_blob_destroy);
345 face = hb_face_create(faceBlob.get(), ttcIndex); 346 face = hb_face_create(faceBlob.get(), ttcIndex);
346 } 347 }
347 348
(...skipping 26 matching lines...) Expand all
374 m_platformData->setupPaint(&m_harfBuzzFontData->m_paint); 375 m_platformData->setupPaint(&m_harfBuzzFontData->m_paint);
375 m_harfBuzzFontData->m_rangeSet = rangeSet; 376 m_harfBuzzFontData->m_rangeSet = rangeSet;
376 m_harfBuzzFontData->m_simpleFontData = FontCache::fontCache()->fontDataFromF ontPlatformData(m_platformData).get(); 377 m_harfBuzzFontData->m_simpleFontData = FontCache::fontCache()->fontDataFromF ontPlatformData(m_platformData).get();
377 ASSERT(m_harfBuzzFontData->m_simpleFontData); 378 ASSERT(m_harfBuzzFontData->m_simpleFontData);
378 int scale = SkiaScalarToHarfBuzzPosition(m_platformData->size()); 379 int scale = SkiaScalarToHarfBuzzPosition(m_platformData->size());
379 hb_font_set_scale(m_unscaledFont, scale, scale); 380 hb_font_set_scale(m_unscaledFont, scale, scale);
380 return m_unscaledFont; 381 return m_unscaledFont;
381 } 382 }
382 383
383 } // namespace blink 384 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698