Skip to content

Commit e38beb9

Browse files
authored
Fixed memory leaks in watches and callback API-s (#83)
1 parent 81304b8 commit e38beb9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/future.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ MaybeValue fdbFutureToCallback(napi_env env, FDBFuture *f, napi_value cbFunc, Ex
181181
napi_value callback;
182182
NAPI_OK_OR_RETURN_STATUS(env, napi_get_reference_value(env, ctx->cbFunc, &callback));
183183
NAPI_OK_OR_RETURN_STATUS(env, napi_reference_unref(env, ctx->cbFunc, NULL));
184+
NAPI_OK_OR_RETURN_STATUS(env, napi_delete_reference(env, ctx->cbFunc));
184185

185186
size_t argc = 1; // In case of error we just won't populate argv[1].
186187
napi_value argv[2] = {}; // (err, value).
@@ -306,6 +307,7 @@ MaybeValue watchFuture(napi_env env, FDBFuture *f, bool ignoreStandardErrors) {
306307
napi_value jsWatch;
307308
NAPI_OK_OR_RETURN_STATUS(env, napi_get_reference_value(env, ctx->jsWatch, &jsWatch));
308309
NAPI_OK_OR_RETURN_STATUS(env, napi_reference_unref(env, ctx->jsWatch, NULL));
310+
NAPI_OK_OR_RETURN_STATUS(env, napi_delete_reference(env, ctx->jsWatch));
309311

310312
// Unlink the handle to the future.
311313
NAPI_OK_OR_RETURN_STATUS(env, napi_remove_wrap(env, jsWatch, NULL));

0 commit comments

Comments
 (0)