Skip to content

Commit

Permalink
fix: fix memory leaks of async callcontext.
Browse files Browse the repository at this point in the history
  • Loading branch information
andycall committed Nov 7, 2024
1 parent 1999438 commit e65cdf3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bridge/core/binding_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,14 @@ static void handleAsyncInvokeCallback(ScriptPromiseResolver* resolver,
if (success_result != nullptr) {
ScriptValue result = ScriptValue(resolver->context()->ctx(), *success_result, false);
resolver->Resolve(result.QJSValue());
dart_free(success_result);
} else if (error_msg != nullptr) {
ExceptionState exception_state;
exception_state.ThrowException(context->ctx(), ErrorType::InternalError, error_msg);
JSValue exception_value = ExceptionState::CurrentException(context->ctx());
resolver->Reject(exception_value);
JS_FreeValue(context->ctx(), exception_value);
dart_free((void*) error_msg);
} else {
assert(false);
}
Expand Down
1 change: 1 addition & 0 deletions webf/lib/src/foundation/binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -410,5 +410,6 @@ void asyncInvokeBindingMethodFromNativeImpl(WebFViewController view, Pointer<Bin
f(asyncCallContext.ref.resolver, nullptr, '$e\n$stack'.toNativeUtf8());
}

malloc.free(asyncCallContext);
}

0 comments on commit e65cdf3

Please sign in to comment.