SurfaceTexture: fix an out of bounds array access
Bug: 6879028
Change-Id: Ic3d35a9384c0a6dfa4000e7743a6f6859608b0bf
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index 68b9feb..a2aca8f 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -316,7 +316,7 @@
computeCurrentTransformMatrix();
} else {
if (err < 0) {
- ALOGE("updateTexImage failed on acquire %d", err);
+ ST_LOGE("updateTexImage failed on acquire %d", err);
}
// We always bind the texture even if we don't update its contents.
glBindTexture(mTexTarget, mTexName);
@@ -327,7 +327,7 @@
}
void SurfaceTexture::setReleaseFence(int fenceFd) {
- if (fenceFd == -1)
+ if (fenceFd == -1 || mCurrentTexture == BufferQueue::INVALID_BUFFER_SLOT)
return;
sp<Fence> fence(new Fence(fenceFd));
if (!mEGLSlots[mCurrentTexture].mReleaseFence.get()) {
@@ -337,7 +337,7 @@
String8("SurfaceTexture merged release"),
mEGLSlots[mCurrentTexture].mReleaseFence, fence);
if (!mergedFence.get()) {
- ALOGE("failed to merge release fences");
+ ST_LOGE("failed to merge release fences");
// synchronization is broken, the best we can do is hope fences
// signal in order so the new fence will act like a union
mEGLSlots[mCurrentTexture].mReleaseFence = fence;