SF: Don't use pointer if promote() fails

Bug 25759725

Change-Id: I51f82154bf86ded24503c07f1932b115aa709cd4
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 1c2c05d..2b6e0ec 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -953,12 +953,13 @@
             // then it is expired or otherwise invalid. Allow this transaction
             // to be applied as per normal (no synchronization).
             mCurrentState.handle = nullptr;
+        } else {
+            auto syncPoint = std::make_shared<SyncPoint>(
+                    mCurrentState.frameNumber);
+            handleLayer->addSyncPoint(syncPoint);
+            mRemoteSyncPoints.push_back(std::move(syncPoint));
         }
 
-        auto syncPoint = std::make_shared<SyncPoint>(mCurrentState.frameNumber);
-        handleLayer->addSyncPoint(syncPoint);
-        mRemoteSyncPoints.push_back(std::move(syncPoint));
-
         // Wake us up to check if the frame has been received
         setTransactionFlags(eTransactionNeeded);
     }