BufferQueueProducer: Slot may have null buffer

I'm not entirely sure how we got in to this state
but it seems best not to crash. It seems like we
are tearing down and everything will work out
in the end anyway.

Bug: 153913134
Test: Existing tests pass
Change-Id: I1d21fa5f29ca1478ecf8e7cd6363f6f176ae9bee
diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp
index 3f4c5da..520d0be 100644
--- a/libs/gui/BufferQueueProducer.cpp
+++ b/libs/gui/BufferQueueProducer.cpp
@@ -655,8 +655,9 @@
         }
 
         listener = mCore->mConsumerListener;
-        if (listener != nullptr) {
-            listener->onFrameDetached(mSlots[slot].mGraphicBuffer->getId());
+        auto gb = mSlots[slot].mGraphicBuffer;
+        if (listener != nullptr && gb != nullptr) {
+            listener->onFrameDetached(gb->getId());
         }
         mSlots[slot].mBufferState.detachProducer();
         mCore->mActiveBuffers.erase(slot);