-
-
Notifications
You must be signed in to change notification settings - Fork 70
fix: parameter and return type bugs in peer connection wrapper #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: parameter and return type bugs in peer connection wrapper #368
Conversation
@murat-dogan noticed the unordered parameter uses negation (!). Is this intentional or we should fix that too? Also, node-datachannel/src/polyfill/RTCPeerConnection.ts Lines 364 to 365 in d83ba00
The polyfill expects Should I create a separate PR to fix the polyfill layer mapping? |
Critical bug (may be related with #366)Found a serious memory safety issue in node-datachannel/src/cpp/peer-connection-wrapper.cpp Lines 620 to 622 in d83ba00
The Instead of passing a pointer to a local stack variable, we need to heap-allocate the Fix for auto dataChannel = mRtcPeerConnPtr->createDataChannel(label, init);
// Allocate a *heap* copy of the shared_ptr
auto heapPtr = new std::shared_ptr<rtc::DataChannel>(dataChannel);
// Pass heapPtr into External, and tell N-API how to clean it up
auto instance = DataChannelWrapper::constructor.New({
Napi::External<std::shared_ptr<rtc::DataChannel>>::New(
info.Env(),
heapPtr,
[](Napi::Env /*env*/, std::shared_ptr<rtc::DataChannel>* p) {
delete p; // deletes the heap-allocated shared_ptr
}
)
});This way:
Same fix needed for |
|
@murat-dogan just checking in to see if you had a chance to review this PR. |
|
Hello @mertushka , I am on holiday and will check them as soon as when I return. |
|
@murat-dogan Knew it, enjoy your |
|
Thanks. I need to check this separately |
No description provided.