GPUShaderInterface: Fix use after free crash

This commit is contained in:
2020-08-20 17:56:01 +02:00
parent 89ee260ef2
commit 5a957c0299
2 changed files with 5 additions and 6 deletions

View File

@@ -171,10 +171,9 @@ void GLVaoCache::clear(void)
}
for (int i = 0; i < count; i++) {
if (interfaces[i] == NULL) {
continue;
if (interfaces[i] != NULL) {
const_cast<GLShaderInterface *>(interfaces[i])->ref_remove(this);
}
const_cast<GLShaderInterface *>(interfaces[i])->ref_add(this);
}
if (is_dynamic_vao_count) {

View File

@@ -277,9 +277,9 @@ void GLShaderInterface::ref_add(GLVaoCache *ref)
void GLShaderInterface::ref_remove(GLVaoCache *ref)
{
for (auto *ref_iter : refs_) {
if (ref_iter == ref) {
ref_iter = NULL;
for (int i = 0; i < refs_.size(); i++) {
if (refs_[i] == ref) {
refs_[i] = NULL;
break; /* cannot have duplicates */
}
}