Bug 1278452 - Fix up bad null checks in Skia. r=lsalzman.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 08 Jun 2016 14:12:10 +1000
changeset 301036 3a6de98f92e604b3bb6d47e7d70c871c396bdc38
parent 301035 77a4d658b09a702e656980405e6ec65f557434bc
child 301037 d31c4e9e910d1ea3cad06449943c17675c51392a
push id19599
push usercbook@mozilla.com
push dateWed, 08 Jun 2016 10:16:21 +0000
treeherderfx-team@81f4cc3f6f4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1278452
milestone50.0a1
Bug 1278452 - Fix up bad null checks in Skia. r=lsalzman.
gfx/skia/skia/src/pathops/SkPathOpsWinding.cpp
gfx/skia/skia/src/ports/SkFontMgr_win_dw.cpp
gfx/skia/skia/src/utils/win/SkDWriteFontFileStream.cpp
--- a/gfx/skia/skia/src/pathops/SkPathOpsWinding.cpp
+++ b/gfx/skia/skia/src/pathops/SkPathOpsWinding.cpp
@@ -284,20 +284,20 @@ bool SkOpSpan::sortableTop(SkOpContour* 
     for (int index = 0; index < count; ++index) {
         hit = sorted[index];
         if (!hit->fValid) {
             return false;
         }
         bool ccw = ccw_dxdy(hit->fSlope, dir);
 //        SkASSERT(!approximately_zero(hit->fT) || !hit->fValid);
         SkOpSpan* span = hit->fSpan;
-        SkOpSegment* hitSegment = span->segment();
         if (!span) {
             return false;
         }
+        SkOpSegment* hitSegment = span->segment();
         if (span->windValue() == 0 && span->oppValue() == 0) {
             continue;
         }
         if (last && SkDPoint::ApproximatelyEqual(*last, hit->fPt)) {
             return false;
         }
         if (index < count - 1) {
             const SkPoint& next = sorted[index + 1]->fPt;
--- a/gfx/skia/skia/src/ports/SkFontMgr_win_dw.cpp
+++ b/gfx/skia/skia/src/ports/SkFontMgr_win_dw.cpp
@@ -40,17 +40,17 @@ public:
     virtual HRESULT STDMETHODCALLTYPE CreateStreamFromKey(
         void const* fontFileReferenceKey,
         UINT32 fontFileReferenceKeySize,
         IDWriteFontFileStream** fontFileStream);
 
     // Takes ownership of stream.
     static HRESULT Create(SkStreamAsset* stream, StreamFontFileLoader** streamFontFileLoader) {
         *streamFontFileLoader = new StreamFontFileLoader(stream);
-        if (nullptr == streamFontFileLoader) {
+        if (nullptr == *streamFontFileLoader) {
             return E_OUTOFMEMORY;
         }
         return S_OK;
     }
 
     SkAutoTDelete<SkStreamAsset> fStream;
 
 private:
@@ -105,17 +105,17 @@ public:
 
     // IDWriteFontFileEnumerator methods
     virtual HRESULT STDMETHODCALLTYPE MoveNext(BOOL* hasCurrentFile);
     virtual HRESULT STDMETHODCALLTYPE GetCurrentFontFile(IDWriteFontFile** fontFile);
 
     static HRESULT Create(IDWriteFactory* factory, IDWriteFontFileLoader* fontFileLoader,
                           StreamFontFileEnumerator** streamFontFileEnumerator) {
         *streamFontFileEnumerator = new StreamFontFileEnumerator(factory, fontFileLoader);
-        if (nullptr == streamFontFileEnumerator) {
+        if (nullptr == *streamFontFileEnumerator) {
             return E_OUTOFMEMORY;
         }
         return S_OK;
     }
 private:
     StreamFontFileEnumerator(IDWriteFactory* factory, IDWriteFontFileLoader* fontFileLoader);
     virtual ~StreamFontFileEnumerator() { }
 
@@ -202,17 +202,17 @@ public:
         IDWriteFactory* factory,
         void const* collectionKey,
         UINT32 collectionKeySize,
         IDWriteFontFileEnumerator** fontFileEnumerator);
 
     static HRESULT Create(IDWriteFontFileLoader* fontFileLoader,
                           StreamFontCollectionLoader** streamFontCollectionLoader) {
         *streamFontCollectionLoader = new StreamFontCollectionLoader(fontFileLoader);
-        if (nullptr == streamFontCollectionLoader) {
+        if (nullptr == *streamFontCollectionLoader) {
             return E_OUTOFMEMORY;
         }
         return S_OK;
     }
 private:
     StreamFontCollectionLoader(IDWriteFontFileLoader* fontFileLoader)
         : fRefCount(1)
         , fFontFileLoader(SkRefComPtr(fontFileLoader))
--- a/gfx/skia/skia/src/utils/win/SkDWriteFontFileStream.cpp
+++ b/gfx/skia/skia/src/utils/win/SkDWriteFontFileStream.cpp
@@ -134,17 +134,17 @@ const void* SkDWriteFontFileStream::getM
 
 ///////////////////////////////////////////////////////////////////////////////
 //  SkIDWriteFontFileStreamWrapper
 
 HRESULT SkDWriteFontFileStreamWrapper::Create(SkStreamAsset* stream,
                                               SkDWriteFontFileStreamWrapper** streamFontFileStream)
 {
     *streamFontFileStream = new SkDWriteFontFileStreamWrapper(stream);
-    if (nullptr == streamFontFileStream) {
+    if (nullptr == *streamFontFileStream) {
         return E_OUTOFMEMORY;
     }
     return S_OK;
 }
 
 SkDWriteFontFileStreamWrapper::SkDWriteFontFileStreamWrapper(SkStreamAsset* stream)
     : fRefCount(1), fStream(stream) {
 }