From 8f03b47432f007b1fb3438608361ebf4e3a1310b Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 10 Dec 2009 15:52:29 -0800 Subject: [PATCH] fix [2319255] crash in openGL : from the media recorder stress test. never call eglCreateImageKHR() with a NULL native buffer, which can happen in OOM conditions. --- libs/surfaceflinger/Layer.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp index f11bf1846..b12c749f2 100644 --- a/libs/surfaceflinger/Layer.cpp +++ b/libs/surfaceflinger/Layer.cpp @@ -134,7 +134,14 @@ void Layer::reloadTexture(const Region& dirty) { Mutex::Autolock _l(mLock); sp buffer(getFrontBufferLocked()); - int index = mFrontBufferIndex; + if (buffer == NULL) { + // this situation can happen if we ran out of memory for instance. + // not much we can do. continue to use whatever texture was bound + // to this context. + return; + } + + const int index = mFrontBufferIndex; // create the new texture name if needed if (UNLIKELY(mTextures[index].name == -1U)) {