Skip to content

Commit b0f2c6f

Browse files
langxiongjasongin
authored andcommitted
Reference: fix constructor miss some member variables initialize. (#74)
1 parent d45ba72 commit b0f2c6f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

napi-inl.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ inline Reference<T>::Reference() : _env(nullptr), _ref(nullptr), _suppressDestru
16171617

16181618
template <typename T>
16191619
inline Reference<T>::Reference(napi_env env, napi_ref ref)
1620-
: _env(env), _ref(ref) {
1620+
: _env(env), _ref(ref), _suppressDestruct(false) {
16211621
}
16221622

16231623
template <typename T>
@@ -1632,26 +1632,28 @@ inline Reference<T>::~Reference() {
16321632
}
16331633

16341634
template <typename T>
1635-
inline Reference<T>::Reference(Reference<T>&& other) {
1636-
_env = other._env;
1637-
_ref = other._ref;
1635+
inline Reference<T>::Reference(Reference<T>&& other)
1636+
: _env(other._env), _ref(other._ref), _suppressDestruct(other._suppressDestruct) {
16381637
other._env = nullptr;
16391638
other._ref = nullptr;
1639+
other._suppressDestruct = false;
16401640
}
16411641

16421642
template <typename T>
16431643
inline Reference<T>& Reference<T>::operator =(Reference<T>&& other) {
16441644
Reset();
16451645
_env = other._env;
16461646
_ref = other._ref;
1647+
_suppressDestruct = other._suppressDestruct;
16471648
other._env = nullptr;
16481649
other._ref = nullptr;
1650+
other._suppressDestruct = false;
16491651
return *this;
16501652
}
16511653

16521654
template <typename T>
1653-
inline Reference<T>::Reference(const Reference<T>& other) {
1654-
_env = other.Env();
1655+
inline Reference<T>::Reference(const Reference<T>& other)
1656+
: _env(other._env), _ref(nullptr), _suppressDestruct(false) {
16551657
HandleScope scope(_env);
16561658

16571659
napi_value value = other.Value();

0 commit comments

Comments
 (0)