exeldro / obs-shaderfilter

OBS Studio filter for applying an arbitrary shader to a source.
GNU General Public License v2.0
377 stars 39 forks source link

Fix memory leaks #1

Closed norihiro closed 2 years ago

norihiro commented 2 years ago

Description

Correctly release allocated memories. Also skip processing the shader if gs_effect_create returns NULL.

Motivation and Context

OBS reported memory leaks like below.

Number of memory leaks: 49

Just FYI, I traced the memory leaks with my custom OBS Studio. https://github.com/obsproject/obs-studio/compare/master...norihiro:bmem-trace-memory-leak

How Has This Been Tested?

Tested on my custom build on Linux (Fedora 34).

Preparation:

  1. Start OBS
  2. Add the filter to a scene.
  3. Exit OBS

When testing:

  1. Start OBS with a scene collection that has the filter attached to a scene
  2. Open the property and modify some text in the shader.
  3. Exit OBS
  4. Check the number of memory leaks.

The log shows no memory leaks as below.

info: Number of memory leaks: 0

Types of changes