diff --git a/src/anbox/graphics/emugl/Renderer.cpp b/src/anbox/graphics/emugl/Renderer.cpp index a1e422806f82a0f4e9d50e0bdfd7b6a25523fbf1..cc8ddcba7aefd4834720e8f01fa223276821c03c 100644 --- a/src/anbox/graphics/emugl/Renderer.cpp +++ b/src/anbox/graphics/emugl/Renderer.cpp @@ -107,7 +107,7 @@ void Renderer::resumeColorBuffer(ColorBufferRef* cbRef) { return; } if (cbRef->closedTs != 0 && eraseDelayedCloseColorBufferLocked(cbRef->cb->getHndl(), cbRef->closedTs)) { - cbRef->refcount++; + cbRef->refcount = 1; cbRef->closedTs = 0; int tid = tInfo->m_tid; if (tid > 0) { @@ -636,7 +636,7 @@ void Renderer::closeColorBufferLocked(HandleType p_colorbuffer, bool wannaClean) // to give guest a notice yet) return; } - if (--(*c).second.refcount == 0) { + if ((*c).second.refcount > 0 && --(*c).second.refcount == 0) { c->second.closedTs = getCurrentLocalTimeStamp(); m_colorBufferDelayedCloseList.push_back( {c->second.closedTs, p_colorbuffer});