GPUShaderInterface: Fix use after free crash
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 */
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user