Avoid crash when setting buffer on deleted layer
When setLayerBuffer() was called on a layer previously destroyed by
destroyLayer() the code would crash. Instead, return an error.
Bug: 37159844
Test: Ran vr flinger in a way that would trigger the crash, and
confirmed that I now get error logs instead of crashing. Unfortunately
the error code is consumed by the Composer wrapper class and not
propagated back to the caller, but that's a separate issue (b/37901601).
Change-Id: I75a5b954d47a1deac44d03851f60f347085eca89
diff --git a/graphics/composer/2.1/default/ComposerClient.h b/graphics/composer/2.1/default/ComposerClient.h
index c973351..3d10f80 100644
--- a/graphics/composer/2.1/default/ComposerClient.h
+++ b/graphics/composer/2.1/default/ComposerClient.h
@@ -173,7 +173,7 @@
Error lookupBuffer(BufferCache cache, uint32_t slot,
bool useCache, buffer_handle_t handle,
buffer_handle_t* outHandle);
- void updateBuffer(BufferCache cache, uint32_t slot,
+ Error updateBuffer(BufferCache cache, uint32_t slot,
bool useCache, buffer_handle_t handle);
Error lookupLayerSidebandStream(buffer_handle_t handle,
@@ -182,9 +182,9 @@
return lookupBuffer(BufferCache::LAYER_SIDEBAND_STREAMS,
0, false, handle, outHandle);
}
- void updateLayerSidebandStream(buffer_handle_t handle)
+ Error updateLayerSidebandStream(buffer_handle_t handle)
{
- updateBuffer(BufferCache::LAYER_SIDEBAND_STREAMS,
+ return updateBuffer(BufferCache::LAYER_SIDEBAND_STREAMS,
0, false, handle);
}