From 22e48cd492b650da5586017cb7c80adcfb760851 Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Thu, 11 Jul 2024 01:10:25 +0300 Subject: [PATCH] chore: fix destructor --- src/node-opus.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node-opus.cc b/src/node-opus.cc index 478c2fb..59c9e55 100644 --- a/src/node-opus.cc +++ b/src/node-opus.cc @@ -44,6 +44,7 @@ Object OpusEncoder::Init(Napi::Env env, Object exports) { OpusEncoder::OpusEncoder(const CallbackInfo& args): ObjectWrap(args) { this->encoder = nullptr; this->decoder = nullptr; + this->outPcm = nullptr; if (args.Length() < 2) { Napi::RangeError::New(args.Env(), "Expected 2 arguments").ThrowAsJavaScriptException(); @@ -68,7 +69,7 @@ OpusEncoder::~OpusEncoder() { this->encoder = nullptr; this->decoder = nullptr; - delete this->outPcm; + if (this->outPcm) delete this->outPcm; this->outPcm = nullptr; }