avisynth: Only increase refcount when fully initialized
When Avisynth is not installed or not functional, this would otherwise cause a crash when trying to initialize Avisynth more than once, since after the first time the refcount would have been incrased anyway.
This commit is contained in:
parent
fe77a1a0b8
commit
f5a730fa45
1 changed files with 3 additions and 1 deletions
|
@ -67,7 +67,7 @@ const AVS_Linkage *AVS_linkage = nullptr;
|
||||||
typedef IScriptEnvironment* __stdcall FUNC(int);
|
typedef IScriptEnvironment* __stdcall FUNC(int);
|
||||||
|
|
||||||
AviSynthWrapper::AviSynthWrapper() {
|
AviSynthWrapper::AviSynthWrapper() {
|
||||||
if (!avs_refcount++) {
|
if (!avs_refcount){
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define CONCATENATE(x, y) x ## y
|
#define CONCATENATE(x, y) x ## y
|
||||||
#define _Lstr(x) CONCATENATE(L, x)
|
#define _Lstr(x) CONCATENATE(L, x)
|
||||||
|
@ -94,6 +94,8 @@ AviSynthWrapper::AviSynthWrapper() {
|
||||||
if (!env)
|
if (!env)
|
||||||
throw AvisynthError("Failed to create a new avisynth script environment. Avisynth is too old?");
|
throw AvisynthError("Failed to create a new avisynth script environment. Avisynth is too old?");
|
||||||
|
|
||||||
|
avs_refcount++;
|
||||||
|
|
||||||
AVS_linkage = env->GetAVSLinkage();
|
AVS_linkage = env->GetAVSLinkage();
|
||||||
|
|
||||||
// Set memory limit
|
// Set memory limit
|
||||||
|
|
Loading…
Reference in a new issue