diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-08-20 18:56:01 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-08-20 18:57:05 +0300 |
commit | 5a957c0299539f571029d7d96ff77367a596eff2 (patch) | |
tree | 68953b0db0e2a7e233d41603b9b14908012e89a3 /source/blender/gpu | |
parent | 89ee260ef22e27c9064dad54331c4c595f23b7e5 (diff) |
GPUShaderInterface: Fix use after free crash
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/opengl/gl_batch.cc | 5 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_shader_interface.cc | 6 |
2 files changed, 5 insertions, 6 deletions
diff --git a/source/blender/gpu/opengl/gl_batch.cc b/source/blender/gpu/opengl/gl_batch.cc index 8dd4c6c21c0..9ca0a9f71db 100644 --- a/source/blender/gpu/opengl/gl_batch.cc +++ b/source/blender/gpu/opengl/gl_batch.cc @@ -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) { diff --git a/source/blender/gpu/opengl/gl_shader_interface.cc b/source/blender/gpu/opengl/gl_shader_interface.cc index ae292f6cc38..423db5c8c97 100644 --- a/source/blender/gpu/opengl/gl_shader_interface.cc +++ b/source/blender/gpu/opengl/gl_shader_interface.cc @@ -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 */ } } |