Skip to content

Commit

Permalink
avisynth: Decrease refcount again when constructor fails
Browse files Browse the repository at this point in the history
Proper fix to the issue that f5a730f
was trying to fix.

Fixes #61 .
  • Loading branch information
arch1t3cht committed Oct 15, 2023
1 parent a9eed18 commit 858f4ac
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/avisynth_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
// Allocate storage for and initialise static members
namespace {
int avs_refcount = 0;
bool failed = false;
#ifdef _WIN32
HINSTANCE hLib = nullptr;
#else
Expand All @@ -66,7 +67,7 @@ const AVS_Linkage *AVS_linkage = nullptr;

typedef IScriptEnvironment* __stdcall FUNC(int);

AviSynthWrapper::AviSynthWrapper() {
AviSynthWrapper::AviSynthWrapper() try {
if (!avs_refcount++) {
#ifdef _WIN32
#define CONCATENATE(x, y) x ## y
Expand Down Expand Up @@ -101,6 +102,9 @@ AviSynthWrapper::AviSynthWrapper() {
if (memoryMax)
env->SetMemoryMax(memoryMax);
}
} catch (AvisynthError const&) {
avs_refcount--;
throw;
}

AviSynthWrapper::~AviSynthWrapper() {
Expand Down

0 comments on commit 858f4ac

Please sign in to comment.