Skip to content
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 Alloc-Dealloc mismatches #1943

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

zawata
Copy link
Contributor

@zawata zawata commented Oct 17, 2022

An Alloc-Dealloc Mismatch causes undefined behavior. Kind of a minor problem but should be fixed nonetheless.

for more details
https://stackoverflow.com/a/10854437/4776273

for (uint32_t i = 0; i < tempArray->Length(); ++i) {
auto conversionResult = Configurable{{ arg.arrayElementCppClassName }}::fromJavascript(
nodegitContext,
Nan::Get(tempArray, i).ToLocalChecked()
);

if (!conversionResult.result) {
delete[] baton->{{ arg.name }};
// TODO free previously allocated memory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this still need to be handled?

Copy link
Contributor Author

@zawata zawata Nov 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julianmesa-gitkraken this comment came from you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but I will do it in another PR. I need to store all allocated memory in a map, then if I get an error reading javascript arguments we have to release all allocated memory, then throw the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants