SurfaceTexture: fix an out of bounds array access

Bug: 6879028
Change-Id: Ic3d35a9384c0a6dfa4000e7743a6f6859608b0bf
This commit is contained in:
Jamie Gennis 2012-08-06 17:10:57 -07:00
parent 1a4d883dcc
commit 45cb2ba1d5

View File

@ -316,7 +316,7 @@ status_t SurfaceTexture::updateTexImage(BufferRejecter* rejecter) {
computeCurrentTransformMatrix(); computeCurrentTransformMatrix();
} else { } else {
if (err < 0) { 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. // We always bind the texture even if we don't update its contents.
glBindTexture(mTexTarget, mTexName); glBindTexture(mTexTarget, mTexName);
@ -327,7 +327,7 @@ status_t SurfaceTexture::updateTexImage(BufferRejecter* rejecter) {
} }
void SurfaceTexture::setReleaseFence(int fenceFd) { void SurfaceTexture::setReleaseFence(int fenceFd) {
if (fenceFd == -1) if (fenceFd == -1 || mCurrentTexture == BufferQueue::INVALID_BUFFER_SLOT)
return; return;
sp<Fence> fence(new Fence(fenceFd)); sp<Fence> fence(new Fence(fenceFd));
if (!mEGLSlots[mCurrentTexture].mReleaseFence.get()) { if (!mEGLSlots[mCurrentTexture].mReleaseFence.get()) {
@ -337,7 +337,7 @@ void SurfaceTexture::setReleaseFence(int fenceFd) {
String8("SurfaceTexture merged release"), String8("SurfaceTexture merged release"),
mEGLSlots[mCurrentTexture].mReleaseFence, fence); mEGLSlots[mCurrentTexture].mReleaseFence, fence);
if (!mergedFence.get()) { 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 // synchronization is broken, the best we can do is hope fences
// signal in order so the new fence will act like a union // signal in order so the new fence will act like a union
mEGLSlots[mCurrentTexture].mReleaseFence = fence; mEGLSlots[mCurrentTexture].mReleaseFence = fence;